Android:从精细到粗糙的 GPS 回退 [英] Android: GPS fallback from fine to coarse

查看:19
本文介绍了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 回退的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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