从Android的apk文件阅读活动名称 [英] Reading Activity names from apk file in Android

查看:121
本文介绍了从Android的apk文件阅读活动名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提取一个Android APK文件中的所有活动的名称。 任何想法怎么可能是可以做到的?

I want to extract all the activities names from an android apk file. Any idea how possibly it can be done?

感谢名单 KAPS

推荐答案

您可以使用PackageManager方法<一href="http://developer.android.com/reference/android/content/pm/PackageManager.html#getPackageArchiveInfo%28java.lang.String,%20int%29">getPackageArchiveInfo检索一个APK文件中的信息。假设你的APK生活在你的SD卡的根目录下,你可以使用这个code:

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文件阅读活动名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆