I would like to display the android:versionName from AndroidManifest in my applications Info (About) page. Any way to do that?
2 Answers
android:versionName="@string/verName"
Get version name in the code as follows
String version = getResources().getString(R.string.verName);
-
Ah, I see. Define the version in strings.xml and then reference that string in AndroidManifest. I may try that as well. Thanks!– wufooCommented Nov 21, 2012 at 15:35
try {
PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0);
version = pi.versionName;
} catch (NameNotFoundException e) {
version = "1.0";
}