There is not a way to directly get the version out, but there are two work-arounds that could be done.
-
The version could be stored in a resource string, and placed into the manifest by:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.somepackage" android:versionName="@string/version" android:versionCode="20">
-
One could create a custom view, and place it into the XML. The view would use this to assign the name:
context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
Either of these solutions would allow for placing the version name in XML. Unfortunately there isn’t a nice simple solution, like android.R.string.version
or something like that.