1. 程式人生 > >獲取打包後的apk版本資訊方法

獲取打包後的apk版本資訊方法

String filePath = "/sdcard/feijiedemo.apk";  
PackageManager packageManager = getPackageManager();  
PackageInfo packageInfo = packageManager.getPackageArchiveInfo(filePath, PackageManager.GET_ACTIVITIES);  
Log.d("name", packageInfo.packageName);  
Log.d("uid", packageInfo.sharedUserId);  
Log.d("vname", packageInfo.versionName);  
Log.d("code", packageInfo.versionCode+"");  

記錄一下。說不定以後就用到了。