How Can I Make My Outdated App Version Show A Dialog That An Update Is Available?
I am just new to android programming, so let's say i have an app of version 1.0 .. then i released another version for the same app, let's say version 1.1 .. what code should i add
Solution 1:
you can build the alert dialog on the first version, when you upload new version to google play you can notify your app with gcm. and ask it to show the alertDialog.
1.save appVersion variable in sharedPref.
2.in your application startup :
if(appVersion != getAppVersion(context))
{
showAlertDialog()
}
privatestaticintgetAppVersion(Context context) {
try {
PackageInfopackageInfo= context.getPackageManager()
.getPackageInfo(context.getPackageName(), 0);
return packageInfo.versionCode;
} catch (NameNotFoundException e) {
// should never happenthrownewRuntimeException("Could not get package name: " + e);
}
}
3.when you have a new update,send the new version number (by gcm) and edit your sharedPref.
Post a Comment for "How Can I Make My Outdated App Version Show A Dialog That An Update Is Available?"