MyLocationOverlay 与 LocationManager 以及后台服务

发布于 2024-11-04 15:33:10 字数 418 浏览 1 评论 0原文

我正在开发一个应用程序。我与朋友分享我的位置(非常像谷歌纬度)。我有一个作为守护进程运行的服务:它应该显示接收到的位置,并每 x 秒发布当前用户位置。

现在,作为 Android 和地图的新手,我对 MyLocationOverlay 和 LocationManager 有点困惑。

在尝试 MapActivity 时,我正在使用 MyLocationOverlay,它似乎非常方便地显示我的位置。问题是,我不确定它从哪里获取位置(网络,gps,..?)以及更新它的频率。此外,我想我不能在 MapActivity 之外使用它,因此无论如何我都需要使用 LocationManager 。

问题是:使用 LocationManager 进行后台工作并使用 MyLocationOverlay 只显示我的位置会太多吗?我想只使用 LocationManager 会更好,对吗?

I am developing an app. in which I share my location with friends (very much like google latitude). I have a service which is running as daemon: it should display received locations, and publish current user location each x seconds.

Now, being quite new to Android and Maps, I am a bit confused about MyLocationOverlay and LocationManager.

While experimenting with the MapActivity, I am using MyLocationOverlay which seems very handy to display my location. Problem is, I am not sure where it is taking the location from (net, gps,.. ?) and how often it updates it. Moreover, I suppose I cannot use it outside the MapActivity, hence I'll need to use the LocationManager anyway.

The question is: using the LocationManager to do the background work and MyLocationOverlay to only show my location would be too much? I suppose it would be better to only use the LocationManager, right?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小红帽 2024-11-11 15:33:10

将 MyLocationOverlay 与 LocationManager 结合使用非常常见。 MyLocationOverlay 通过 GPS 确定位置,然后通过 Wifi 确定位置。您可以为 MyLocationOverlay 和 LocationManager 指定用于位置确定的网络。

两种类型的位置查找都会存储位置(换句话说,如果您有 MyLocationOverlay 和 LocationManager,则它不会两次轮询 GPS,而只会使用两者最后接收到的位置)。 GPS 或 WiFi 接收到的最后位置会全局存储到任何确定位置的应用程序中。

所以回答你的问题,不,使用 LocationManager 和 MyLocationOverlay 并不算太多。

Using MyLocationOverlay in conjunction with LocationManager is very common. MyLocationOverlay determines location from GPS, then Wifi. You can specify the networks to use for location determination both for MyLocationOverlay and with a LocationManager.

The location is stored for both types of location finding (in other words, if you have a MyLocationOverlay as well as LocationManager, it's not going to poll the GPS twice as hard, its simply going to use the last-received location for both). The last location received by GPS or wifi is stored globally to any application that determines a location.

So to answer your question, no, using a LocationManager as well as a MyLocationOverlay is not too much.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文