Android app not updating when application is opened - android

I'm releasing a single app purpose that I update through google play store.
For those who do not know, a single app purpose is an app that is supposed to run alone on a device.
Therefore I give away the device the app, and prevent the users to use any other apps.
Anyway, I start the app automatically on boot. The devices reboot every day at 5 AM.
I've noticed that the google play store checks for updates when the device boots.
Unfortunately, it seems that the update won't perform while the app is opened.
To this I have 2 questions :
Is this odd behavior of update familiar to anybody (having the update not performing for the currently running apps)
How to solve this?
PS: I did think of updating the app versionCode on a third party server and if it's not up to date, close the app, let the update perform, then receive when the update is done performing to re-open the app.
But honestly, it feels like killing a fly with the bazooka.

I think you should depend on external server for this purpose.
App not being updated when running in foreground makes sense because Google play is not supposed to stop a running app which is necessary for updating it.
I recommend you to use Firebase cloud messaging service for the purpose. You can easily send data to the device using FCM.

Related

I don't want my Android app to auto-update onto users devices

We're currently running tests (that end in 2 weeks) with clients using an "older" version of our app.
The older app has a long-running scanner foreground service that will not restart on the MY_PACKAGE_UPDATE broadcast (wasn't implemented at the time). The new version of the app correctly handles this broadcast and restarts the scanning on MY_PACKAGE_UPDATE.
We need to roll out updates mid-test to fix a bug appearing on only some devices, and we are able to reach out to those specific users. The problem is that for any current users with auto-update turned on, their foreground scanning service will exit and not restart.
Am I correct that the MY_PACKAGE_UPDATE broadcast won't kick in yet? As in, it'll only begin working two updates from now?
Is there a way for me to turn off auto-updating for my app in the play store for all users?

What is the application flow after Google Store update?

I'm trying to understand what exactly happens after my app gets updated on the users devices.
As of course the 'MainActivity' isn't launched, I am wondering about the services.
I have one START_STICKY service and one which is not, does the START_STICKY auto-start after the update, what about the other ?
Is there any way of testing this behavior without waiting for a real Play Store update ?
I looked for a documentation regarding this issue but couldn't find anything related.
I just did a quick test. Not sure how close this is to an actual update on the Play Store or if it is in any way comparable, but here goes:
I have created a simple app that starts two services on the click of a button, one START_STICKY one START_NOT_STICKY.
Both services create a notification in onStartCommand() and show a version number.
I create one release APK, change the version number in Manifest and notification, and create another release APK. I've copied the two APKs onto the phone and disconnected the phone.
I've manually installed the first APK on the phone, started the app, clicked the button, two notifications appear. Installed the second APK, without starting the app. The two notifications disappeared and did not re-appear either. Opened the app, clicked the button, both notifications appeared with the new version number.
From this it appears that neither service will be restarted automatically after an app update.
You could also publish your app on Google Play as an Alpha version and test an update of your app without annoying general users.

How to prevent android app from updating from the google play store?

I have an android app that is published in the Google Play Store. The Google Play Store app is how end-users install updates. I realize it's up to the user's discretion to turn on auto-updates, so this feature may or may not be turned on with any given phone.
My app runs a foreground service with an icon in the notification bar when it's running. During testing of the auto-update procedure, I noticed that if the service is running and the app updates itself, the service is shutdown (which is to be expected since new code is being installed).
However, I would like to avoid this if at all possible. What I would like to happen is find a way to detect when auto-update tries to update my app. If the service is running, I'd like to deny updates until the service finishes it's work and shuts down.
So is there any way to detect when the google play store attempts to update your app, and if so, is there a way to block the update until you determine your app is in a safe state to shutdown?
Unfortunately, I don't think there is a way to detect when the Play Store attempts to update your app, unless you have a second app to listen for this event. And even if you have a way to detect this, I don't think you can cancel the update.
Maybe it would be an idea for you to transfer the work you are doing to your second app while the first one is being updated. However, I needn't say that this sounds like a very hacky solution.
You should focus on saving your state and continuing from where you left after the application is updated and started.

programmatically temporarily disable auto-update

I have a Bike computer app that logs data while the user is riding. I have had a user report an issue I had not considered. He was out for a long ride (100+ miles) but while out and logging data the app got updated via Google plays auto-update. This unfortunately killed off the app mid recording and the user lost data till they spotted what had happened and restarted the app.
Ideally I would like to be able to programmatic stop the auto-update happening while the app is data logging. All my research indicates that this is not possible possible but I may of missed something so dose anyone know of a way of doing this?
Given no solution the best I can do is advice the users to enable the update only over wifi option in the Play app which in this instance would of helped. Unfortunately one of the key points about my app is that it will log indoor sessions using ANT+ sensors so I have a good number of people using it with wifi active.
Edit
I managed to do the experiment to see what happens myself last night. I had an app going in the background data logging then pushed a new version to Google Play. Unfortunatly it was not picked up totaly automaticaly when I had to leave 10 hours latter but I opened up the play store app and it found the update it did not start updating automaticaly but I forced it. The act of downloading and installing the new version killed off what was in progress. It was already dead before I used the notification to go to the new version.
As you say yourself, you can't do that what you are asking for. You could hack your way around it by changing the permissions each time you update. The users will then be prompted about it in the regular way.
I'm not sure about the "life-cycle" for automatic updated apps that are running. But I read somewhere that is wasn't the re-install but the reopen of the app that crashed it. If that is the case you could set a flag indicating that the user is currently logging and then on restart just resume the logging. But again we need to know more about the inner workings of activities/apps which are running and get an automatic update (actually didn't think it could happen).
Edit
Based on your findings I'd say you have to handle the app is shut down in onDestroy etc. or/and make sure you save everything persistently. Then you might need to have 2 apps where 1 listens to the other being re installed and when that happens it starts it up again (there is an interesting discussion here). If you are targeting api >= 12 then the broadcast action ACTION_MY_PACKAGE_REPLACED might also have interest.

Android application update - how to?

What is the best way to let my users perform an application update?
Is there any way to force device reboot after the update? I'm asking this because my application registers some behavior on boot.
Please note, the application would not be published in the Market.
Update:
My app will be preinstalled on a set of ~100 handsets.
Should I periodically call a webservice that will inform the device about upgrade available, and then, redirect to an .apk file within a webkit view?
What is the best way to let my users
perform an application update?
Via the same way they got the app on their device in the first place, presumably. If they are getting the app via firmware, they get app updates via firmware updates. If they are downloading your app via your Web site, they get app updates via your Web site.
Is there any way to force device
reboot after the update?
No, thank goodness.
I'm asking this because my application
registers some behavior on boot.
There is some way you can be notified that your package was updated, though I do not have the technique handy right now. Just run your on-boot logic there for the first round, then subsequent reboots (if any) will be handled by the on-boot logic itself.

Categories

Resources