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 名称


- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01