1

I would like to display the android:versionName from AndroidManifest in my applications Info (About) page. Any way to do that?

2 Answers 2

7

android:versionName="@string/verName"

Get version name in the code as follows

String version = getResources().getString(R.string.verName);

1
  • Ah, I see. Define the version in strings.xml and then reference that string in AndroidManifest. I may try that as well. Thanks!
    – wufoo
    Commented Nov 21, 2012 at 15:35
3
    try {
        PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0);
        version = pi.versionName;
    } catch (NameNotFoundException e) {
        version = "1.0";
    }

Not the answer you're looking for? Browse other questions tagged or ask your own question.