所以这是我的代码:
public static void SetMockLocation()
{
var context = Android.App.Application.Context;
var locationManager = context.GetSystemService(LocationService) as LocationManager;
locationManager.AddTestProvider("Test299", false, false, false, false, false, false, false, Power.Low, Android.Hardware.SensorStatus.AccuracyHigh);
locationManager.SetTestProviderEnabled("Test299", true);
var location = new Location("Test299");
location.Latitude = Add700ToCoordinates();
location.Longitude = GlobalLongitude;
location.Accuracy = 0; // ob das geht?... ja, aber was beduetet es?
location.Time = DateTime.Now.Ticks;
location.ElapsedRealtimeNanos = 100; // hier das gleiche... was hießt es? :D
locationManager.SetTestProviderLocation("Test299", location);
//Do something here?
locationManager.RemoveTestProvider("Test299");
}
所以我启动应用程序,它的工作原理。现在,当我进入谷歌地图时,我希望它能让我把我的新坐标显示在哪里。但我仍然在地图上获得我的原始位置。我错过了什么?
谢谢!
****编辑:
我认为这可能与应用程序没有在后台运行有关。如果是这样,即使应用程序在后台,我怎么能一遍又一遍地重复这个方法?
谢谢:)