问候,
当我没有修复时,有没有人知道如何获得粗略的GPS坐标,并且当我修复时获得精确的GPS坐标?
我试过谷歌搜索一些示例代码无济于事。
我确实找到了这个: http : //www.android10.org/index.php/articleslocationmaps/226-android-location-providers-gps-network-passive
但我不知道如何实现回退到粗略/升级到罚款。
我希望有人能帮帮忙。 提前致谢,
Greetings,
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.
I did find this: 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,
最满意答案
您可以在文档中找到关于该主题的出色介绍。 基本思想是您启用侦听来自不同提供程序的更新。 收到新位置后,将其与先前存储的位置进行比较(上述链接中提供了一个示例函数)。
位置对象具有可用于衡量其准确性的getAccuracy 。 您还应该设置一个计时器,以便了解位置提供程序提供更新后经过的时间。 如果GPS提供商给您更新后超过两分钟,则开始侦听网络更新。 在收听网络更新时,如果GPS为您提供新的更新,请切换到正常位置。
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).
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.
更多推荐
GPS,粗略,知道,know,电脑培训,计算机培训,IT培训"/> <meta name="description&qu
发布评论