What is the meaning of android.location.LocationManager.PASSIVE_PROVIDER?

折月煮酒 提交于 2019-12-03 14:19:34

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!