安卓GPS由细后备粗 [英] Android: GPS fallback from fine to coarse

查看:110
本文介绍了安卓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?

我已经尝试使用Google的一些示例code无济于事。

I've tried googling for some sample code to no avail.

我没有找到这样的:<一href="http://www.android10.org/index.php/articleslocationmaps/226-android-location-providers-gps-network-passive" rel="nofollow">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,

推荐答案

您可以找到一个很好的介绍中的文档。的基本思路是,你启用监听来自不同的供应商的更新。当接收到一个新的位置,你把它比作previous存储位置(样本函数是在上面的链接提供的)。

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为您提供了一个新的更新,然后切换到精确的位置信息。

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由细后备粗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆