1String versionName = context.getPackageManager()
2 .getPackageInfo(context.getPackageName(), 0).versionName;
1PackageManager manager = this.getPackageManager();
2PackageInfo info = manager.getPackageInfo(this.getPackageName(), PackageManager.GET_ACTIVITIES);
3Toast.makeText(this,
4 "PackageName = " + info.packageName + "\nVersionCode = "
5 + info.versionCode + "\nVersionName = "
6 + info.versionName + "\nPermissions = " + info.permissions, Toast.LENGTH_SHORT).show();
1private String getCurrentVersion(){
2PackageManager pm = this.getPackageManager();
3PackageInfo pInfo = null;
4
5 try {
6 pInfo = pm.getPackageInfo(this.getPackageName(),0);
7
8 } catch (PackageManager.NameNotFoundException e1) {
9 e1.printStackTrace();
10 }
11 String currentVersion = pInfo.versionName;
12
13 return currentVersion;
14 }