Android: GPS fallback from fine to coarse(Android:从精细到粗糙的 GPS 回退)
问题描述
您好,
有谁知道我如何在没有修复时获取粗略的 GPS 坐标,而在修复时获取精细的 GPS 坐标?
Does anyone know how I can get coarse GPS coordinates when I don't have a fix and get fine GPS coordinates when I have a fix?
我尝试在谷歌上搜索一些示例代码,但无济于事.
I've tried googling for some sample code to no avail.
我确实找到了这个:http://www.android10.org/index.php/articleslocationmaps/226-android-location-providers-gps-network-passive
但我不知道如何实现回退到粗略/升级到精细.
But I don't know how to implement the fallback to coarse/upgrade to fine.
我希望有人可以提供帮助.提前致谢,
I hope someone can help. Thanks in advance,
推荐答案
您可以在 文档.基本思想是您可以侦听来自不同提供者的更新.收到新位置后,将其与之前存储的位置进行比较(上面的链接中提供了示例函数).
You can find an excellent introduction to the subject in the documentation. The basic idea is that you enable listening for updates from different providers. When a new location is received, you compare it to the previous stored location (a sample function is provided in the above link).
位置对象有一个 getAccuracy
,您可以使用它来衡量其准确性.您还应该设置一个计时器,以便您知道位置提供商提供更新后经过了多长时间.如果 GPS 提供商为您提供更新后超过两分钟,则开始侦听网络更新.在侦听网络更新时,如果 GPS 为您提供了新的更新,则切换到正确的位置.
A location object has an getAccuracy
that you can use to measure its accuracy. You should also set up a timer so that you know how long has passed after a location provider has provided an update. If more than two minutes have passed after GPS provider has given you an update, then start listening for network updates. While listening for network updates, if GPS gives you a new update, then switch to fine location.
这篇关于Android:从精细到粗糙的 GPS 回退的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android:从精细到粗糙的 GPS 回退


- Android viewpager检测滑动超出范围 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android - 拆分 Drawable 2022-01-01