I want to display the versionName ( number) located in the android manifest on my spalsh screen. I found some example codes but they are not working. This seems like a simple task but it does not display for me
text view from splash xml:
<TextView
android:id="@+id/ver_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="33dp"
android:layout_marginRight="30dp"
android:text=" " />
display method:
private void displayVersionName() {
String versionName = "";
PackageInfo packageInfo;
try {
packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
versionName = "ver:" + packageInfo.versionName;
} catch (NameNotFoundException e) {
e.printStackTrace();
}
TextView tv = (TextView) findViewById(R.id.ver_name);
tv.setText(versionName);
}
Log.i("displayVersionName", "Version: " + versionName);
. I can't see anything wrong with the code you're showing here.