1
votes

My service records the location of the user and sends it to Firebase every X minutes. I have tried changing X from 1 minute to 5 minutes, however the change in battery drain was less than 1 percent. In both cases it works out at about 5% used by the app every 3 hours.

I am trying to understand how increasing the GPS interval by 500% had little or no impact on the battery life. Not only is the GPS firing 1/5 of the time, but there is also 1/5 of the data being sent/received to Firebase.

When the watching location is turned off, battery drain is 0.

Any ideas as to what is causing the drain? Also, what kind of battery drain should I be looking at for getting a GPS location every 5 mins and sending about 50 bytes of data with it?

2
Cleaning up comments...Frank van Puffelen

2 Answers

1
votes

An immediate concern is how you connect to Firebase. Keep in mind that Firebase will keep an open connection to the server from the moment you call new Firebase(...). If you only want to periodically send/listen for data, you'll needlessly be draining the battery.

You can programmatically manage the connection state with goOffline()/goOnline().

If you're only sending updates, you can use the Firebase REST API to write the updates. This won't keep an open connection, or at least leaves it up to Android to determine when to close the connection.

0
votes

Turned out the major cause was the mobile data. As soon as I made it require wifi to use firebase the battery drain dropped from 20% a day to 2%.