通过网络请求位置更新时出现问题

发布于 2024-10-04 10:31:33 字数 858 浏览 4 评论 0原文

我创建了一项服务并获取有关用户的位置数据,以便我可以向用户显示附近的地点。除了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

甚是思念 2024-10-11 10:31:33

您是否在 API 级别 13 或更高级别的模拟器上运行? Android 问题 19857

are you running on emulator at api level 13 or greater? Android issue 19857

心如荒岛 2024-10-11 10:31:33

安全与安全中的使用无线网络设置位置首选项设置。是否启用?

Use wireless networks setting in Security & location preference settings. Is it enabled?

独夜无伴 2024-10-11 10:31:33

可能是 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 use LocationManager.getBestProvider (Criteria criteria, boolean enabledOnly)'.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文