I've been playing around with android.R.attr.versionName, which I first saw on this question. This claims to show the version of the app, but I've tried a couple of things that just don't seem to work:
View as a TextView, just shows number:
<TextView ... android:text="?android:attr/versionName"/>
Get as a string, returns a null pointer exception:
TypedValue value=new TypedValue(); getActivity().getTheme().resolveAttribute(android.R.attr.versionName,value,true); String version=value.coerceToString().toString();
Any other thoughts? It seems rather useless if there isn't a way to get to the version from either code or XML.
I do know that there are other ways to get the version name, and I'm not interested in them, I'm just curious about this specific variable, and what it's use is.