Thursday, 29 June 2017

Get android:versionName manifest element in code



I want to know how to parse the AndroidManifest.xml file in order to get the Application Version Number through code. android:versionName



Answer



No need to parse the AndroidManifest.xml file for this.



You can get this by using:



try
{
String app_ver = this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName;
}
catch (NameNotFoundException e)

{
Log.e(tag, e.getMessage());
}


Use this inside your onCreate() method.


No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...