1

I have in mind the force the user to update the application when there is a new update.

To accomplish this I had thought in the versionCode, obtain the versionCode of the application installed on the device:

public int getVersion() {
    int v = 0;
    try {
        v = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    return v;
}

And now i would need to know my server update versionCode.

Knowing the update versionCode and comparing it with the application of user versionCode i could check if it is different.

My ultimate goal is to check if there is an update. And if it exists, does not open the current application while the user does not update.

Any idea for this?

Thanks

jlopez
  • 6,287
  • 2
  • 51
  • 90
  • 1
    I have an open source update checking library for Android [here](https://github.com/RaghavSood/AppaholicsUpdateChecker). It does the same version checking that you ask for, and you can find a nice implementation in the code. However, it doesn't do the don't start until update part, so you'll have to make some changes if you use it – Raghav Sood Feb 26 '13 at 11:00
  • I'll try your code, thank you – jlopez Feb 26 '13 at 11:26

1 Answers1

0

If your want to get the version of your app that is available on Google Play that is not possible as far as I know. You will need your own web server (call a web service to get the version number or just access a "secret" file on your server to read it) and than, popup the upgrade dialog. If you go for this solution make sure you don't update the server version too early. After getting a new application on Google Play it will take them a few hours until it becomes available to all users.

azertiti
  • 3,110
  • 16
  • 19
  • Thanks for the answer, i found this http://stackoverflow.com/questions/7298106/android-app-check-for-latest-app-version – jlopez Feb 26 '13 at 11:20