我想从一个 android apk 文件中提取所有活动名称.知道怎么可能做到吗?
I want to extract all the activities names from an android apk file. Any idea how possibly it can be done?
谢谢卡普斯
可以使用PackageManager方法getPackageArchiveInfo 从 APK 文件中检索信息.假设您的 APK 位于 SD 卡的根目录中,您可以使用以下代码:
You can use the PackageManager method getPackageArchiveInfo to retrieve the information from an APK file. Assuming your APK lives in the root of your SD card, you can use this code:
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 对象中找到大量其他信息.
There is plenty of additional information you can find in the ActivityInfo and PackageInfo objects.
这篇关于从 Android 中的 apk 文件中读取 Activity 名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!