Android:GPS从精细到粗略的回退(Android: GPS fallback from fine to coarse)

编程入门 行业动态 更新时间:2024-10-25 08:24:20
Android:GPS从精细到粗略的回退(Android: GPS fallback from fine to coarse)

问候,

当我没有修复时,有没有人知道如何获得粗略的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

本文发布于:2023-08-07 00:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1458800.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:精细   GPS   Android   coarse   fine

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!