解决方法
您可以使用PackageManager方法
getPackageArchiveInfo从APK文件中检索信息.假设您的APK存储在SD卡的根目录中,可以使用以下代码:
String apkPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/MyApp.apk"; PackageManager pm = getPackageManager(); PackageInfo info = pm.getPackageArchiveInfo(apkPath,PackageManager.GET_ACTIVITIES); //Log.i("ActivityInfo","Package name is " + info.packageName); for (android.content.pm.ActivityInfo a : info.activities) { Log.i("ActivityInfo",a.name); }
在ActivityInfo和PackageInfo对象中可以找到大量附加信息.