Skip to content

Instantly share code, notes, and snippets.

@fnzainal
Forked from jbaginski/PackageManagerInfo.java
Last active November 21, 2016 00:41
Show Gist options
  • Save fnzainal/7623f32ad0983610df29967fedcd032c to your computer and use it in GitHub Desktop.
Save fnzainal/7623f32ad0983610df29967fedcd032c to your computer and use it in GitHub Desktop.
android build details
package org.example;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.content.pm.PackageInfo;
class PackageManagerInfo extends Activity {
public void onCreate() {
super.onCreate();
try {
PackageInfo packageInfo = getPackageManager()
.getPackageInfo(getPackageName(), 0);
String versionName = packageInfo.versionName;
int versionCode = packageInfo.versionCode;
String packageName = packageInfo.packageName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment