I need to figure out how to get or make a build number for my Android application. I need the build number to display in the UI.
Do I have to do something with
Always do it with try catch block:
String versionName = "Version not found";
try {
versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
Log.i(TAG, "Version Name: " + versionName);
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
Log.e(TAG, "Exception Version Name: " + e.getLocalizedMessage());
}