问题
I have a shopping app on playstore.
There are many new updates which the user must have.
The new Apk needs to be update by all users.
How can I force all my users to update their app?
回答1:
Hmm you can do this by below approach.
- Add an updated code version of your app to the server
- Make a web service that return that version code you placed on server
If you have BaseActivity do the third on that else do the third step on that activity that is first Activity or launcher Activity
In onResume method hit that service and get App version code and match that code with current app code. If both are same then it is ok else Prompt the user and take the user out of the app by killing the app. NTOE: You can use below code to get the current version of the app that is installed in your device.
PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); String version = pInfo.versionName;
Hope that helps you.
回答2:
Have a file on a server which contains version of the most recently released APK. On app startup get the file and compare current APK version with what is the latest version. At that point you can either let the user continue or gracefully direct them to the Play Store.
You'll have to update the file on the server every time you update the APK, but additionally you can provide additional controls or messages that you can show like when a old version will no longer work to give your users time to upgrade.
Regardless you'll have to code this into the app before the user gets it.
回答3:
Yes you can, You have to manage apk current version with web service. Need to follow below steps,
Whenever your app is started call any service which is sending your current app version and based on this server send response like "0" or "1" as pre-defined. if you got above value like "0" for existing app and "1" for app update now you can manage the dialog or some actionable view which is redirect app to your playstore app.
That's all! This way you can forcefully update app.
Happy Coding!!!
回答4:
You can use appgrades.io to provide a customised view in your app blocking the navigation and asking the user to update the app. No need to manage app versioning in your app/api if you could use third party librairies that perform such a task.
回答5:
You can't do this. Your API must work with an old versions of your APK. And remember that user can uninstall some of your updates.
As a last resort you may check a version of API in APK, show warning and don't let use your application.
来源:https://stackoverflow.com/questions/47386846/how-to-force-user-to-update-the-app