无法在设备上获取 GPS 读数

发布于 2024-11-07 18:24:59 字数 698 浏览 1 评论 0原文

我已经花了几天时间尝试使用 Android 设备获取位置。由于 API 级别较高,我无法使用 requestSingleUpdate。由于准确性问题,我也不想单独使用 getLastKnownLocation 。因此我选择使用 requestLocationUpdates。

(为简单起见,我将参考此代码,但我使用了多种方法来使用 GPS 来使用 requestLocationUpdates:在 Android 上获取用户当前位置的最简单、最可靠的方法是什么?

我可以使用手机信号塔获取位置,但其准确性不够好。每当我尝试获取 GPS 位置时,即使我让监听器离开 5 分钟,onLocationChanged 也永远不会被调用。在 GPS 读取部分期间,GPS 图标确实出现在我的通知栏中。我确实设置了获取粗略+精细位置的权限,并且我的 GPS 在 Google 地图和 GPS 测试中运行良好。即使我去谷歌地图获得准确的锁定然后切换到我的应用程序,我也永远不会得到位置更新。我向我认识的人询问了解决方案或原因,但没有得到答复。我也在网上进行了很多搜索以寻求解决方案,但空手而归。我是否遗漏了什么,或者我永远无法获得更准确的位置读数?

I have been working for days in attempting to obtain a location using Android devices. I cannot use requestSingleUpdate due to a high API level. I also do not want to use getLastKnownLocation by itself due to accuracy issues. Therefore I have opted for using requestLocationUpdates.

(For simplicity I will refer to this code, but I have used many approaches to using requestLocationUpdates using GPS: What is the simplest and most robust way to get the user's current location on Android?)

I can get a location using the cell towers, but its accuracy is not good enough. Whenever I try to obtain a location for GPS onLocationChanged is never called, even if I let the listener go for 5 minutes. The GPS icon does appear in my notification bar during the GPS reading part. I do have permissions set for getting a coarse+fine location, and my GPS is working fine in Google Maps and GPS Test. Even if I go to Google Maps to get an accurate lock then switch to my application, I never get a location update. I have asked people I know for a solution or a reason and have been left without a response. I also have done many searches around the net for a solution and have left empty-handed. Is there anything that I am missing or am I never going to get a more accurate location reading?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

眼前雾蒙蒙 2024-11-14 18:24:59

您提到您已设置获取精细位置的权限,但是获取粗略位置又如何呢?一个好的实现将在可能的情况下使用精细位置更新,在不可能的情况下使用粗略的位置更新。仅仅因为显示 GPS 图标并不意味着您有锁。

您可以在这里阅读有关此问题的更多信息:

http://developer .android.com/guide/topics/location/obtaining-user-location.html

You mention that you have permissions set for getting FINE locations, but what about getting COARSE locations? A good implementation will use FINE location updates when possible and COARSE location updates when not. Just because you have a GPS icon showing does not mean you have a lock.

You can read up on this issue more here:

http://developer.android.com/guide/topics/location/obtaining-user-location.html

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