In some cases there is a need to know if user has installed or updated your app. For example to put different texts or something else. To do this you may use code below:
static public boolean isUpdated(Context ctx) {
PackageInfo packageInfo = null;
try {
packageInfo = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(),
PackageManager.GET_ACTIVITIES);
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Can't get package info");
}
return (packageInfo.firstInstallTime != packageInfo.lastUpdateTime);
}
No comments:
Post a Comment
Post your comment here