[英]Retrieve the version code of the App in Android
try {
ComponentName comp = new ComponentName(this, [CURRENT_ACTIVITY].class);
PackageInfo pinfo = getPackageManager().getPackageInfo(comp.getPackageName(), 0);
int versionCode = pinfo.versionCode;
} catch(android.content.pm.PackageManager.NameNotFoundException e) {}
Replace "[CURRENT_ACTIVITY]" with the actual name of your activity. 用活动的实际名称替换“ [CURRENT_ACTIVITY]”。 (Just to clarify haha) (只是为了澄清哈哈)
context
.
context
.
getPackageManager
().
getPackageManager
().
getPackageInfo
(context.
getPackageName
()).
getPackageInfo
(context.
getPackageName
()).
versionCode
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.