拿到本地apk的verisoncode 和已安装的apk verisoncode

转: http://www.maxiaoguo.com/shipin/330.html

//检查本地apk的的verisoncode

File file = FileUtil.getDownloadFile(gameDetail.packageName);
PackageManager pm = this.getPackageManager();
PackageInfo packageInfo = pm.getPackageArchiveInfo(file.getAbsolutePath(), PackageManager.GET_ACTIVITIES);
if(packageInfo!=null){
packgeVersionCode  = packageInfo.versionCode;
LogTag.showTAG_e("tag", "本地apk的的verisoncode"+packgeVersionCode +"---");

}


//检查已安装的apk的versioncode

 PackageManager mManager = getPackageManager();

PackageInfo info = mManager.getPackageInfo(gameDetail.packageName, 0);
int versionCode =info.versionCode;
//拿到服务器给的verisoncode
int infoVersion = gameDetail.versionCode;
LogTag.showTAG_e("tag", "已安装的apk的versioncode"+versionCode+"---");

你可能感兴趣的:(File,服务器,null)