1

I have a service which tracks the user's location all the time (as long as its running) and puts the data into a SQL table, and when the app is in the foreground -> the service also sends updates to the UI with the location and the map and location are updated.

  1. When app is in foreground -> request the location with high accuracy and frequent updates so the user can enjoy the high accuracy and frequent updates in the UI.
  2. When app is closed (only service running) -> request a less-accurate-location updates, so I don't consume too much battery, because all I do is fill a table.

So, what are the factors affecting battery use when tracking the location?

In the docs sample

protected void createLocationRequest() {
    LocationRequest mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(10000);
    mLocationRequest.setFastestInterval(5000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); 
} 

They say that

The priority of PRIORITY_HIGH_ACCURACY, combined with the ACCESS_FINE_LOCATION permission setting that you've defined in the app manifest, and a fast update interval of 5000 milliseconds (5 seconds), causes the fused location provider to return location updates that are accurate to within a few feet.

So, this is what I would use when the app is in the foreground (in the settings I can see the app has a "high battery use" with the location).

but what parameters should I change when only the service is running? I want the location using will be saying: "low battery use".

Ofek Agmon
  • 5,040
  • 14
  • 57
  • 101

0 Answers0