Android Question Upgrade app that runs 24x7

CaptKronos

Active Member
Licensed User
Longtime User
Hi, I have an app that runs 24x7 on users' devices and will be available on the Play Store. What I'm trying to work out is the best way to install new versions of the app. Ideally, upgrades won't require user interaction. What I don't understand is how Android updates installed apps. I can envisage three different approaches that Android might take when a new update becomes available on the Play Store:
1. Android downloads the update and then waits for the app to not be running before installing the update. When the user next runs the app, they will be using the new version.
2. Android downloads the update, forces a termination of the app, installs the update and then restarts the app.
3. Android never downloads an update while an app is running.

Can anyone tell me which of 1 to 3 is correct, or if there is another approach that's used? I can accommodate 1 and 2, but I'm not sure how it would be best to handle 3.

Thanks.
 

JohnC

Expert
Licensed User
Longtime User
If "Auto-Update" is enabled in Play Store, I believe android (play store) will auto-update your app and then do nothing (it will not auto-run your app).

You will probably need to look into information about intents such as "PACKAGE_REPLACED":


As a last resort this might work: Have your app call the "startserviceat" function on a regular basic (like once an hour). So if the play store auto-updates your app and causes it to stop, hopefully the system won't clear the next scheduled event for your app when it's updated so that it will automatically restart your app.
 
Last edited:
Upvote 1

CaptKronos

Active Member
Licensed User
Longtime User
Thanks, that is very useful. I already have a "startserviceat" in my app so that might be sufficient however I guess a newly installed version of the app might cancel any pending "startserviceat" commands. I'll try testing with "adb install -r newversion.apk" as mentioned in the stackoverflow article you referenced.
The weird thing is that I have waited several days for Android to do, whatever it's going to do, after I had uploaded a new version and it doesn't seem to do anything. The old version carried on running regardless. (The Play Store auto update option is enabled.)
 
Upvote 0

CaptKronos

Active Member
Licensed User
Longtime User
I already have a "startserviceat" in my app so that might be sufficient however I guess a newly installed version of the app might cancel any pending "startserviceat" commands. I'll try testing with "adb install -r newversion.apk" as mentioned in the stackoverflow article you referenced.
Just to confirm that this worked, i.e. the new version installed and at the scheduled time, the app started.
 
Upvote 0
Top