I have an Intent Service that is invoked by FusedLocationApi every minute or so to monitor locations periodically via pending .
@Override
protected void onHandleIntent(Intent intent) {
if (intent != null && LocationResult.hasResult(intent)) {
LocationResult locationResult = LocationResult.extractResult(intent);
location = locationResult.getLastLocation();
} else {
Crashlytics.logException(new LocationException("Loc Intent Service invoked without location", new NullPointerException()));
}
}
It is working fine most of the time but in production, in the last 7 days I have received 13,000 events of the service being invoked by the FusedLocationApi without any location. (thanks to the Crashlytics non fatal exception I've added)
Why or when would this happen? I have tried disabling location permission while the locations are being monitored, in which case the service is invoked without location but just once or twice, after which it is never invoked again until I turn location permission back on.