2

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!

Zuhayr
  • 342
  • 4
  • 11
  • 1
    Enabling GPS keeps it on all the time for at least short polling times. I you put it at something like 15 minutes or 1 hour it might turn it off. In general GPS isn't that bad of a battery drain though- keeping the screen on for a few minutes takes more battery than running GPS all day. I'd worry more about accuracy tradeoffs and useful locations (for example GPS fails inside most buildings) than battery usage. – Gabe Sechan Feb 26 '17 at 18:22
  • @GabeSechan, such vauge common wisdom/advice does not cover all cases someone might face. "I would...." may be true in **your** particular case, but not everyone else. In my case, I checked it for several days, gpsd takes around 30% (per day) while screen takes 10%. But again, it just is **my** case. Btw. here is interesting read https://www.quora.com/Battery-Life/Why-does-GPS-use-so-much-more-battery-than-any-other-antenna-or-sensor-in-a-smartphone Search for "Robert Love". – greenoldman May 05 '21 at 14:19
  • @greenoldman Covering every case would require a small book, so yeah, of course a quick comment doesn't cover everything. I suggest you redo your numbers though- there's no way you have a screen on all day and only take 10% battery. I get that in under an hour at 25% brightness. You're greatly overstating GPS drain and understating screen drain on any device I've ever used. – Gabe Sechan May 05 '21 at 14:36
  • @GabeSechan, I don't have to redo anything, I just check battery stats and those are the numbers (again and again). I referred to your claim "keeping the screen on for a **few minutes** takes more battery than running GPS all day" which is my case but the numbers says this claim is not true. Sure thing, screen turned on for **entire day** would take more, but this was not your original statement. – greenoldman May 06 '21 at 14:32
  • @greenoldman Then i suggest you get a new device, something is greatly wrong with yours. I've done this test repeatedly on multiple devices. GPS is a drain, but nowhere near what other things like screen are. – Gabe Sechan May 06 '21 at 14:33
  • @GabeSechan, for now I keep my phone, thank you :-) but I thought maybe we could compare absolute values, not relative. Dividing battery capacity by overall battery drain by given portion of given entity took, I have -- gpsd took 360 mAh (12 hours) while screen 120mAh (within those 12 hours, but it was on for several minutes). GPS refresh rate is 1 sec. – greenoldman May 07 '21 at 20:08

1 Answers1

1

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.

Pablo Baxter
  • 2,144
  • 1
  • 17
  • 36