Reputation: 9103
I can't find information about app's process life cycle when application is being updated by Play Store.
For example when app's process is running and some Service does something and then update starts, I expect that after apk is successfully updated whole process is killed (where "old" app was running) and then process is started again (with "new" app launched).
Would this behavior differ for auto-updated app and manually updated app?
Upvotes: 10
Views: 1402
Reputation: 2896
I've just tested manually the case when you update the application via Play Market (real devices, Samsung tablet with Android 7.0, One Plus with Android version 8.0.0).
Also you can simulate app update by the command adb install -r yourApp.apk
. As it's mentioned here and here.
I've noticed, when application is running and you reinstall the app with the adb command mentioned above, onDestroy
is not called. App is not restarted. And when you start it over - it is created from scratch. Basically, same behavior as when I test manually with Play Market.
As a conclusion, when the app is being updated by Play Market, and it's running (background or foreground), it is simply killed by the system.
Upvotes: 3
Reputation: 503
You can stop the service and start it again by defining a Broadcast Receiver with intent as PACKAGE REPLACED with a check that which package is updated and if it specifies that your application is updated then perform the necessary task. It works for both the auto and manual updates as well.
Upvotes: 0