How to prevent or block app usage by users using old versions of app?

Viewed 693

I would like to ensure that users of my app are always using the latest version. If they haven't updated the app to the latest version, I would like to prevent them from using the app.

What is the best way to do this ? In each activity I can check my apps website to see what the latest version should be, and compare it with the device,but it seems clunky.

Isn't there a better way to display some kind of UI that prevents the user from using any of the other activities ?

4 Answers

Probably the best solution for this is to check BuildConfig.VERSION_CODE and compare it with the version code in the server. Add an alert dialog and redirect it Playstore update screen on the Alert positive response button, and override the onBackPressed() method if the user tries to do anything else. This will force them to update to latest version of the application.

@Override
public void onBackPressed() {
    System.exit(0); // Kill the app
    super.onBackPressed();
}
Related