mennovogel
mennovogel

Reputation: 339

Activity recognition removed after app is updated

I use

ActivityRecognition.ActivityRecognitionApi.requestActivityUpdates(googleApiClient, interval, getPendingIntent());

to track the user's activity, which works fine. But when I install an update by creating a new build with Android Studio, I stop getting activity updates until I call requestActivityUpdates() again. The same happens when I build a release build and update it with a newer release build.

I would like to continue getting activity updates after the user updates my app in future releases, how can I fix this?

Upvotes: 0

Views: 74

Answers (1)

Moonbloom
Moonbloom

Reputation: 7918

You could use a broadcastreceiver that listens for the ACTION_PACKAGE_REPLACED intent.

Copy-pasted from the description:
Broadcast Action: A new version of an application package has been installed, replacing an existing version that was previously installed.

Then simply set up the updates again when this intent is received.

Upvotes: 2

Related Questions