Reading Activity names from apk file in Android(从 Android 中的 apk 文件中读取 Activity 名称)
问题描述
我想从一个 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 名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 Android 中的 apk 文件中读取 Activity 名称


基础教程推荐
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 多个组件的复杂布局 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01