I understand the meaning of GPS_PROVIDER (locations come from GPS signals) and NETWORK_PROVIDER (locations are determined from cell towers and wireless access points), but I don't understand the meaning of PASSIVE_PROVIDER, despite the definition in the 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.
Why would one use this instead of one of the other providers? To save battery life? Does the passive provider only return useful information if some other app explicitly requests data from the real providers, or is it always safe to request locations from this?
To add to @Janusz, when you receive a fix due to someone else's provider and you wish to know from what provider is this fix from (NETWORK or GPS), you can call the getProvider() to find this.
This provider is useful for services that work with the users location but don't want to waste battery life as you pointed out.
For example Google Latitude sends your current location to a web service to let your friends know where you are. If this service would request a GPS fix every 5 minutes the device battery will be empty very fast. If the service requests a passive location provider a location is send every time Google maps is started and a fix aquired or some other apps initiates a location provider update and the service can act on location data without spending additional power on the location updates.
If you need correct location data at an exact moment using this provider won't help. For most things that are not running in a background service this location provider is useless because it will only send updates if other apps trigger an update of the user location.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With