获取更准确的用户位置 android

Get the more accurate user location android

我正在构建一个跟踪用户移动的应用程序。我在网上找到了,但我仍然对如何获得可靠的用户位置感到困惑。

为此,我开始使用 GPS_PROVIDER 每分钟获取一次用户位置。但这会耗尽大量电池。 现在我使用的是 NETWORK_PROVIDER,它的电池电量更好,但据我了解,这并不准确。

因此,首先,我想知道如何处理这些提供商的使用情况,以便在电池消耗和用户定位精度方面取得良好的收益。

其次,我在那里读到 (Significant Motion):

At the high level, the significant motion detector is used to reduce the power consumption of location determination. When the localization algorithms detect that the device is static, they can switch to a low power mode, where they rely on significant motion to wake the device up when the user is changing location.

这是否意味着此传感器已被 GPS_NETWORK 使用或应用程序必须实现所描述的行为?

谢谢

您提供的link(显着运动)与加速度计有关,在实施位置跟踪时您不应该太在意。

您可能需要的是来自 Google Play Services 的 Fused Location Provider API,请在此处阅读更多信息:https://developer.android.com/training/location/index.html。它自动合并来自 GPS 和网络供应商的数据,还可以在应用程序之间同步访问位置信息。它为您提供了相当简单的配置选项(您想要多精确的位置?您希望多久获得一次更新?),并且 Play Services 框架负责以非常有效的方式为您提供位置。

由于这是一个相当广泛的话题,我将只参考您的文档:上面的 link 具体 this section。你也应该找到很多教程。