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 回退
基础教程推荐
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
