通过网络请求位置更新时出现问题
我创建了一项服务并获取有关用户的位置数据,以便我可以向用户显示附近的地点。除了 GPS 之外,我还希望此服务通过网络进行跟踪,原因有 2 个:1) GPS 可能未启用。 2) GPS 需要相当长的时间来锁定我的测试手机。
当我的服务执行以下行时:
mNETEnabled = mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
我收到以下错误:
11-24 14:00:41.693: ERROR/LocationManagerService(51): isProviderEnabled got exception:
11-24 14:00:41.693: ERROR/LocationManagerService(51): java.lang.IllegalArgumentException: provider=network
11-24 14:00:41.693: ERROR/LocationManagerService(51): at com.android.server.LocationManagerService._isProviderEnabledLocked(LocationManagerService.java:1385)
11-24 14:00:41.693: ERROR/LocationManagerService(51): at com.android.server.LocationManagerService.isProviderEnabled(LocationManagerService.java:1359)
这是为什么?我是否缺少清单的许可?我的清单中有 ACCESS_COARSE_LOCATION。
I've created a Service and grabs location data about the user so I can show my users nearby places. I want this Service to track by network in addition to GPS for 2 reasons: 1) GPS may not be enabled. 2) GPS takes quite a bit of time to lock on with my test phone.
When my Service executes the following line:
mNETEnabled = mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
I get the following error:
11-24 14:00:41.693: ERROR/LocationManagerService(51): isProviderEnabled got exception:
11-24 14:00:41.693: ERROR/LocationManagerService(51): java.lang.IllegalArgumentException: provider=network
11-24 14:00:41.693: ERROR/LocationManagerService(51): at com.android.server.LocationManagerService._isProviderEnabledLocked(LocationManagerService.java:1385)
11-24 14:00:41.693: ERROR/LocationManagerService(51): at com.android.server.LocationManagerService.isProviderEnabled(LocationManagerService.java:1359)
Why is this? Am I missing a permission from the Manifest? I have ACCESS_COARSE_LOCATION in my manifest.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否在 API 级别 13 或更高级别的模拟器上运行? Android 问题 19857
are you running on emulator at api level 13 or greater? Android issue 19857
安全与安全中的
使用无线网络
设置位置首选项设置。是否启用?Use wireless networks
setting inSecurity & location
preference settings. Is it enabled?可能是 Moment 没有 AGPS(这很奇怪)。但您可以使用
LocationManager.getAllProviders()
检查并查看哪些返回。您也可以只使用LocationManager.getBestProvider (Criteria criteria, booleanenabledOnly)'
。Could be that the Moment doesn't have AGPS (which would be weird). But you can check with using
LocationManager.getAllProviders()
and see which ones come back. You could also just useLocationManager.getBestProvider (Criteria criteria, boolean enabledOnly)'
.