13 February 2014

how to get my application version name from androd manifest ?

STORY:
I wanted to display version of my application written in Android manifest on screen.

SOLUTION:
This is snippet from my application

private String getMyAppVersionName (){
   try {
     return "version: v" + this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName;
   }catch (PackageManager.NameNotFoundException ntfe){
     return "Unknown";
   }
}


No comments:

Post a Comment