android - android.location.LocationManager.PASSIVE_PROVIDER 是什么意思?

标签 android location locationmanager

我理解 GPS_PROVIDER 的意思(位置来自 GPS 信号)和 NETWORK_PROVIDER (位置由手机信号塔和无线接入点确定),但我不明白 PASSIVE_PROVIDER 的含义,尽管 API 中有定义:

A special location provider for receiving locations without actually initiating a location fix. This provider can be used to passively receive location updates when other applications or services request them without actually requesting the locations yourself. This provider will return locations generated by other providers. You can query the getProvider() method to determine the origin of the location update. Requires the permission android.permission.ACCESS_FINE_LOCATION, although if the GPS is not enabled this provider might only return coarse fixes.

为什么要使用这个而不是其他提供商之一?为了节省电池生命周期?如果某些其他应用程序明确请求来自真实提供者的数据,被动提供者是否仅返回有用的信息,或者从中请求位置总是安全的?

最佳答案

此提供程序对于与用户位置一起使用但又不想像您指出的那样浪费电池生命周期的服务很有用。

例如,谷歌纵横会将您的当前位置发送到网络服务,让您的 friend 知道您的位置。如果此服务每 5 分钟请求一次 GPS 定位,设备电池将很快耗尽。如果该服务请求被动位置提供程序,则每次启动 Google map 并获得修复或某些其他应用程序启动位置提供程序更新时都会发送一个位置,并且该服务可以对位置数据进行操作,而无需在位置更新上花费额外的电量。

如果您需要在准确时刻获得正确的位置数据,使用此提供程序将无济于事。对于大多数不在后台服务中运行的东西,这个位置提供者是无用的,因为它只会在其他应用程序触发用户位置更新时发送更新。

关于android - android.location.LocationManager.PASSIVE_PROVIDER 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5655241/

相关文章:

android - 在 Android 中逐个像素地跟踪运动

android - Fragments 的点击监听器

java - 我如何知道对象何时执行了操作?

ios - 更长时间跟踪用户位置

ios - 位置管理器无法在 iOS 中获得速度

javascript - 如何防止Android浏览器上的键盘改变页面的高度?

android gps 定位时间 ( gettime() ) 方法

javascript - 无限的 Google Places 实例

android - 什么是位置提供者 "passive"?在 HTC Desire with Android 2.2 上看到

ANDROID:帮助 LocationProvider