Search code examples
androidgeolocationandroid-locationfusedlocationproviderapipower-saving

Battery impact of polling for location updates less often?


I've read a lot of conflicting information on this.

Suppose I use the Fused Location API in PRIORITY_HIGH_ACCURACY mode, does it make much difference if I set the interval to, say, 10 minutes vs 1 minute? 1 hour vs 10 seconds? If so, how drastically?

I don't know how it works internally so I'm just wondering what I can do to save battery if I need high accuracy location (and relative infrequency of polling isn't an issue).

https://developer.android.com/training/monitoring-device-state/index.html

The developer site has advice on how to save battery but they don't seem to give any concrete information on exactly how much polling frequency affects battery life.

Does enabling the service keep the GPS on all the time and therefore always using battery (and so the interval would be synthetic and solely for programmatic reasons)?

Thanks!


Solution

  • For Fused Location API, I'm not certain if they turn off GPS or adjust reporting interval while leaving it on, but I would assume they turn off GPS between updates, or else many others would complain about power drain.

    As for what Android Location Service does, they do turn off GPS and allow the phone to idle between updates if the interval is greater than 0 (check out the source in LocationManagerService). I've done quite a bit of power testing on different android phones, and found that keeping the CPU from idling can draw a noticeable amount of power. Add the power draw of GPS (which keeps the CPU from idling) and you are looking at a decent power drain (about 50% of what the screen would draw for some devices).

    In the end, I'd have to agree with Gabe Sechan and advise you on choosing whether accuracy is worth the battery drain. Just ask yourself these basic questions:

    • Do I need to know if my user is on one side of the street or the other?

      If yes, use GPS, else use Network or low accuracy location.

    • How often do I need to check my user's location?

      If you need it about once a minute, set your interval as such. If you only care when they leave a general area, setup a geofence, or use network locations. You can also listen to location updates from other apps, and make your app smarter about when to take updates.

    • If I can't get my user's location within X amount of time, can I skip this update altogether?

      If you can, then put a timeout feature in your update logic. If not, I strongly recommend you re-evaluate the app logic in that case.