Tools - Get Version Code/Name

//Create variable versionName and versionCode

String versionName = "null";
int versionCode = -1;
try {
android.content.pm.PackageInfo packageInfo = MainActivity.this.getPackageManager().getPackageInfo(getPackageName(), 0);
versionName = packageInfo.versionName;
versionCode = packageInfo.versionCode;
} catch (android.content.pm.PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
//textview set text
TextView textViewVersionInfo = (TextView) findViewById(R.id.textview1);
textViewVersionInfo.setText(String.format("Version Name: %s Version Code:%d", versionName, versionCode));

Komentar

Cara pembuatan Apps paling Populer

Create Stopwatch App in Android using Sketchware

How to enable download in webview in Sketchware apps?

TextInputLayout in Sketchware

Create Stopwatch App in Android using Sketchware

How to integrate Admob Ads in Sketchware project using AIDE?

How to find and​ highlight a word in a text field in Sketchware?

Code for implementing Notifications in Sketchware

A Flash Light App in Sketchware

Create a Stopwatch App using Chronometer in Sketchware

Create app to save all passwords, protected using voice key