Auto-restart app after market update

android, auto-update, google-play, service

Solution

It's something you'll have to test carefully but you should be able to catch it with a broadcast receiver with the action Intent.ACTION_PACKAGED_REPLACED

Then you start the service from your receiver.

Problem

Anytime I publish a new version of my app in the Market, if the user had enabled the "auto update" option, the app will be updated automatically. The app contains a service that runs constantly. But when the automatic update happens, the old running app is killed, but the new one is not started. Since the update happens mostly transparently to the user, it makes sense that the app's service should be started again automatically after the update so that there is almost no interruption of the service. It's a bit difficult to test this with a real update from the market, so I'm using the following two adb commands to simulate this update process. Install of the 1st version: ``` adb install oldversion.apk ``` Automatic update: ``` adb install -r newversion.apk ``` After I run the second command, the app gets successfully updated, but it has been stopped and not restarted. How can we make the new version's service start automatically?

Original source

Related problems