What is the best way to log GPS position (or data, to analyze) that wouldn't consume whole battery in few hours on Android? Is there some special way? Some of the tracking software available on market claim to be optimized for low battery usage.
-
To maximise the battery life whilst recording GPS locations, you need to be serious about what you actually need. For example, instead of recording every location you get when you're cycling, switch to a lower resolution and receive locations every 5 metres. – StuStirling Jun 12 '14 at 09:34
-
High resolution would be great. And I mean logging all the time (for example every minute or so), not for a moment of checking. – Flash Thunder Jun 12 '14 at 09:36
-
In one of our apps we update the location every 10m and, depending on the device, we get around 6-9 hours out of them. However, for phones like the Samsung Galaxy Ace this will last24 hours. – StuStirling Jun 12 '14 at 10:08
1 Answers
No matter what exact approach to the code you use (e.g. service, some library, or code your self, etc, etc)... it will ALWAYS narrow down to one question:
How much resolution and how often updates are you requesting?
That's because no matter how it's coded, it will always relies on the same sensors (the GPS, wifi n tower triangulation) that is attached to the same physical hardware, and same battery.
So, general tips for better battery life is to get positions less often, to be ok with less accurate positioning, etc.
The Google Location Services (available on any device that uses Google Play) is a great time saver and it's also a very well optimized piece of code. If you want some example on how to use it feel free to check this app I did in a boring Sunday afternoon:
https://github.com/budius/photogpstag
https://play.google.com/store/apps/details?id=com.budius.photogpstag
In that I optimized for a person walking and taking photos, meaning every 3 or 5 minutes would be a good enough position and have a good lasting battery.
You can grab the source code and change the request parameters to higher accuracy/more often updates and see that the battery drain will increase.

- 39,391
- 16
- 102
- 144
-
I see very often ppl here on StackOverflow wanting to achieve magic when it comes to hardware and sensors. Yesterday there was a guy answering why he can't use the GPS position to measure his living room size. My answer is telling you the reality (a GPS sensor turned on all the time WILL drain the battery), and provided with resources n code example for you to explore what can better fit your needs. – Budius Jun 12 '14 at 10:05
-
so how those apps from store work saying that it reads position every minute? – Flash Thunder Jun 12 '14 at 10:34
-
1Same way as any other. But an app reading position every minute will use more battery than one that read position every 5 min. It's a trade-off that you have to chose. As I said on the answer, 3 to 5 min was my approach because it was optimized for photographer walking. But the code is in GitHub and you're free to check it out and change to whatever your needs are. – Budius Jun 12 '14 at 10:49