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 名称
基础教程推荐
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
