How to list all activities exposed by an application?

前端 未结 4 1443
鱼传尺愫
鱼传尺愫 2020-12-25 07:59

I think that it should be possible to get all the activities from \'third-party\' application, described in the manifest file. I can\'t figure out how.

for example:<

4条回答
  •  孤独总比滥情好
    2020-12-25 08:42

    Thanks for the answer!

    I think I found a solution for listing all the activities in an application too, not the most elegant though...

    //the method gets all activities for an application
    private void getAppActivities() {
        PackageManager pManager = getPackageManager();
        Intent startIntent = setStartIntent();
        List apps = pManager.queryIntentActivities(startIntent, 0);
        int count = apps.size();
        for (int i = 0; i < count; i++) {
            ResolveInfo info = apps.get(i);
            String packageName = info.activityInfo.packageName;
            Intent intent = new Intent();
            intent.setPackage(packageName);
    
            //activities holds the activities defined in the package
            List activities = pManager.queryIntentActivities(intent, 0);
        }
    }
    

提交回复
热议问题