Confusingly, the FusedLocationProviderApi stops sending intents.
A bit more detail: I have an Android service that builds a GoogleApiClient.
mClient = new GoogleApiClient.Builder(this)
.addApi(LocationServices.API)
.addApi(ActivityRecognition.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
mClient.connect();
Once connected, I request location updates using:
// Set up periodic location updates
Intent locationIntent = new Intent(this, LocationReceiver.class);
mLocationPendingIntent = PendingIntent.getBroadcast(
this,
0,
locationIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
mFusedLocationProviderApi.requestLocationUpdates(
mClient,
mLocationRequest,
mLocationPendingIntent);
And I request activities detected using:
// Set up activity recognition
Intent activityRecognizedIntent = new Intent(
this,
ActivityRecognizedReceiver.class);
mActivityRecognizedPendingIntent = PendingIntent.getBroadcast(
this,
0,
activityRecognizedIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
mActivityRecognitionApi.requestActivityUpdates(
mClient,
ACTIVITY_DETECTION_INTERVAL,
mActivityRecognizedPendingIntent);
When the service is killed by the OS, for example when I push a new version of the app to my phone, the ActivityRecognizedReceiver continues to receive updates! How can I stop that from happening? Why does the LocationReceiver stop receiving updates?