I'm using a LocationClient to get the current location every minute:
mLocationRequest = LocationRequest.create();
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationRequest.setInterval(60000);
mLocationRequest.setFastestInterval(60000);
mLocationClient = new LocationClient(this, this, this);
// ... when connected:
mLocationClient.requestLocationUpdates(mLocationRequest, this);
However I noticed that my LocationListener's onLocationChanged-method is called either every 60 or 120 (or any other multiple of 60) seconds (+/- 3 seconds). The documentation says:
This interval is inexact. You may not receive updates at all (if no location sources are available), or you may receive them slower than requested. [...]
So I know, that the interval is not exact one minute. But I thought that I would get the current location as fast as possible after the 60 seconds are over, for example after 75 seconds. But it seems that if the LocationClient cannot determine the location it simply retries after the next 60 seconds.
Is this assumption correct?
If yes, a workaround would be to set the interval to something lower like 30 seconds or so and filter out the required locations in the onLocationChanged-method. But that would probably consume more battery power.
When you call
mLocationRequest.setFastestInterval(60000);
you are saying that you cannot handle more than one call every 60 seconds, hence why it is waiting on 60 second intervals before sending you an update (even if it gets it 45 seconds before the next 60 second period) - lower thesetFastestInterval
to ensure that location updates are sent to you quickly after receiving them. As the actual polling frequency is tied tosetInterval
(and not the fastest interval) increasing yoursetFastestInterval
should not increase battery usage.