当我在模拟器中运行 Monodroid 应用程序时,我很难让它检索位置。我的代码看起来像这样:
LocationManager 位置管理器 = (LocationManager)threadSurfaceView.Context.GetSystemService(Context.LocationService);
位置 = 位置管理器.GetLastKnownLocation(Android.Content.Context.LocationService);
但是,这似乎总是返回 null。我是否必须以某种方式配置模拟器以使其具有位置服务和/或位置?
我还尝试添加一个 LocationListener:
locationListener = new MyLocationListener();
locationManager.RequestLocationUpdates(LocationManager.GpsProvider, 120000, 0, locationListener);
但我在这里遇到的问题是创建 MyLocationListener 类。我实现了四个公共方法(OnLocationChanged(Location) 等),但 Visual Studio 抱怨缺少 Android.Runtime.IJavaObject 方法 - 有人有实现 ILocationListener 的类的简单示例吗?
谢谢你的帮助。马丁