I have a background service with location updates every 12 minutes. We want to test location updates every 5-6 minutes, but in Android documentation we found this:
In an effort to reduce power consumption, Android 8.0 (API level 26) limits how frequently background apps can retrieve the user's current location. Apps can receive location updates only a few times each hour.
https://developer.android.com/about/versions/oreo/background-location-limits.html
Code in the service to receive updates:
mLocationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
Location location = locationResult.getLastLocation();
//...
}
};
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
mLocationRequest = new LocationRequest();
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationRequest.setInterval(TIME_TO_CHECK_LOCATION);
mLocationRequest.setFastestInterval(TIME_TO_CHECK_LOCATION);
mLocationRequest.setMaxWaitTime(TIME_TO_CHECK_LOCATION);
mFusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback, null);
Anyone have tested the limits of location updates in a background service using Android 8?
The limits are a fixed number of times per hour?