-5

I am new to Android App Development. I am making an App to which I want to Add an Update Check Option when the app first launches. Or I can Add a page where the user will click on Update button and the App will check for the update Available.

How can I add it??

Nayan
  • 367
  • 4
  • 18
  • do some google and post if you have errors..that would be a good thing to do know – Tharif Oct 31 '15 at 06:34
  • Please have a look on http://stackoverflow.com/help/how-to-ask If you simply ask how to do? what to do? moderators will make your question as closed or hold. Narrate your problem briefly. what you tried? what you are expecting and whats the error you got. This way community members will give you answers. – Shivanshu Verma Oct 31 '15 at 06:35
  • Thanks for the instant replies & for sharing this information. I'll first try a code and then post the errors id any. – Nayan Oct 31 '15 at 06:43

1 Answers1

2

You can send request to server and get latest version of app.then get current app version with this code:

public static String getAppVersion(Context context) {
    PackageInfo pInfo = null;
    try {
        pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    return pInfo.versionName;
}

then compaire current version with latest version.if needed to update,show dialog for update.

Ahmad Azarnia
  • 129
  • 1
  • 1
  • 11