Reading Android application version name and version code defined in the Manifest file programatically in android
/**
* Method to Fetch Application Name as Defined in Manifest File
* @returns String
*/
public String getVersionName(){
String versionName = "";
try {
versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
} catch (Exception e) {
e.printStackTrace();
}
return versionName;
}
/**
* Method to Fetch Application Number as Defined in Manifest File
* @returns String
*/
public int getVersionNumber(){
int versionNumber = 0;
try {
versionNumber = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
} catch (Exception e) {
e.printStackTrace();
}
return versionNumber;
}
Comments
Post a Comment