What's the most battery-efficient approach of using LocationClient to periodically get updates?

后端 未结 2 1463
生来不讨喜
生来不讨喜 2021-01-02 16:19

I am thinking about having two separate alarms to gather a user\'s location data every hour, one that goes off every 59 minutes to \"connect\" the client and a second to act

2条回答
  •  清酒与你
    2021-01-02 17:08

    See the "Receiving Location Updates" section on the Android developer docs for a detailed discussion of this topic with the new Fused LocationProvider:

    http://developer.android.com/training/location/receive-location-updates.html

    This gives you the option to register an Intent with a LocationListener to the Fused LocationProvider that is automatically triggered by the internal Google Services framework when it is considered "efficient" to do so. I would trust that this framework has a much greater potential to optimize power usage, since it has a lot more knowledge of what else is going on in the system vs. an app-registered Timer.

    Here are your options for registering a listener with different power priority levels, which will result in different levels of battery drain, as listed in the above docs:

    • PRIORITY_BALANCED_POWER_ACCURACY - Used with setPriority(int) to request "block" level accuracy. Block level accuracy is considered to be about 100 meter accuracy. Using a coarse accuracy such as this often consumes less power.
    • PRIORITY_HIGH_ACCURACY - Used with setPriority(int) to request the most accurate locations available. This will return the finest location available (and the greatest potential for energy drain).
    • PRIORITY_NO_POWER - Used with setPriority(int) to request the best accuracy possible with zero additional power consumption. No locations will be returned unless a different client has requested location updates in which case this request will act as a passive listener to those locations.

提交回复
热议问题