Get version name & version code
String sVersionName;
int iVersionCode;
try {
PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
sVersionName = pInfo.versionName;
iVersionCode = pInfo.versionCode;
} catch (PackageManager.NameNotFoundException e) {
sVersionName = "Unknown";
iVersionCode = 1;
}
Version name & version code is from what you have defined in AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.example1"
android:versionCode="14"
android:versionName="1.2.2">
No comments:
Post a Comment