我已经建立了一个简单的应用程序来从HERE获得职位(在HERE开发人员支持的帮助下),问题是answered here
此代码可在我的手机上正常工作,以每分钟在日志中生成一次GeoPosition。
我现在正在尝试在目标平板电脑上运行此代码。平板电脑较旧(运行Android 5.1),没有GPS,并且没有SIM卡或电话连接。唯一可能的定位方法是使用Wifi。我已经在平板电脑上测试了HERE测试应用,并根据Wifi连接找到了一个很好的大概位置-这就是我要复制的内容。
当我尝试使用GPS的LocationMethod或GPS_NETWORK或NETWORK初始化PositionManager时,会出现相同的错误
这些行:
payload
我得到了这些日志:
PositioningManager pm = PositioningManager.getInstance();
PositioningManager.LocationStatus ls = pm.getLocationStatus(PositioningManager.LocationMethod.GPS);
Log.i("Position", "Setting up positioning");
if (ls == PositioningManager.LocationStatus.AVAILABLE) {
Log.i("Position", "Positioning is available");
} else {
Log.w("Position", "Positioning not available right now: " + ls.toString());
}
boolean ret = pm.start(PositioningManager.LocationMethod.GPS);
Log.i("Position", "Positioning start returns " + ret);
每分钟我检查一下位置
01-27 06:00:21.656 16636-16636/? I/Position: Setting up positioning
01-27 06:00:21.657 16636-16636/? W/Position: Positioning not available right now: OUT_OF_SERVICE
01-27 06:00:21.660 16636-16636/? W/System.err: java.lang.IllegalArgumentException: provider doesn't exist: network
01-27 06:00:21.661 16636-16636/? W/System.err: at android.os.Parcel.readException(Parcel.java:1550)
01-27 06:00:21.661 16636-16636/? W/System.err: at android.os.Parcel.readException(Parcel.java:1499)
01-27 06:00:21.661 16636-16636/? W/System.err: at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:582)
01-27 06:00:21.661 16636-16636/? W/System.err: at android.location.LocationManager.requestLocationUpdates(LocationManager.java:899)
01-27 06:00:21.661 16636-16636/? W/System.err: at android.location.LocationManager.requestLocationUpdates(LocationManager.java:500)
01-27 06:00:21.661 16636-16636/? W/System.err: at com.here.android.mpa.internal.v.a(DeviceLocation.java:117)
01-27 06:00:21.661 16636-16636/? W/System.err: at com.here.android.mpa.internal.ea.a(PositioningManagerImpl.java:224)
01-27 06:00:21.661 16636-16636/? W/System.err: at com.here.android.mpa.common.PositioningManager.start(PositioningManager.java:153)
01-27 06:00:21.661 16636-16636/? W/System.err: at com.company.app.MainActivity.setUpPositioning(MainActivity.java:63)
01-27 06:00:21.661 16636-16636/? W/System.err: at com.company.app.MainActivity.onRequestPermissionsResult(MainActivity.java:137)
01-27 06:00:21.661 16636-16636/? W/System.err: at com.company.app.MainActivity.checkPermissions(MainActivity.java:108)
01-27 06:00:21.661 16636-16636/? W/System.err: at com.company.app.MainActivity.onCreate(MainActivity.java:39)
01-27 06:00:21.661 16636-16636/? W/System.err: at android.app.Activity.performCreate(Activity.java:5990)
01-27 06:00:21.661 16636-16636/? W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
01-27 06:00:21.661 16636-16636/? W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
01-27 06:00:21.661 16636-16636/? W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
01-27 06:00:21.661 16636-16636/? W/System.err: at android.app.ActivityThread.access$800(ActivityThread.java:151)
01-27 06:00:21.661 16636-16636/? W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
01-27 06:00:21.661 16636-16636/? W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
01-27 06:00:21.661 16636-16636/? W/System.err: at android.os.Looper.loop(Looper.java:135)
01-27 06:00:21.661 16636-16636/? W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5258)
01-27 06:00:21.661 16636-16636/? W/System.err: at java.lang.reflect.Method.invoke(Native Method)
01-27 06:00:21.661 16636-16636/? W/System.err: at java.lang.reflect.Method.invoke(Method.java:372)
01-27 06:00:21.661 16636-16636/? W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
01-27 06:00:21.661 16636-16636/? W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
01-27 06:00:21.666 16636-16636/? I/Position: Positioning start returns true
,它为null。如果我将LocationMethod设置为NULL,则不会出现异常,但仍不会得到任何GeoPosition。
如何在他们的测试应用中管理它,以便仅从Wifi获得职位?