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
First:
import android.content.pm.PackageManager.NameNotFoundException;
and then use this:
PackageInfo pInfo = null; try { pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); } catch (NameNotFoundException e) { e.printStackTrace(); } String versionName = pInfo.versionName;