android-获得".apk"文件的相关信息。包名、版本号等等

时间:2022-03-19 21:10:30
    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+"");