List of all activities in App

前端 未结 3 1385
借酒劲吻你
借酒劲吻你 2020-12-16 06:13

Is there any way, how to get list of all activities in running app?

I have tried:

ActivityInfo[] list = getPackageManager().getPackageArchiveInfo(
           


        
3条回答
  •  Happy的楠姐
    2020-12-16 06:50

    This code gets list of all the Activities in the application. you can use the same code to get Broadcast Receivers, Services and Content Providers with little editing. Please let me know if there is any way to get the Intent-filters.

    public  String getAllActivities(Context context) {
        try {
            String Activities = "";
            PackageInfo pi = context.getPackageManager().getPackageInfo(
                    context.getPackageName(), PackageManager.GET_ACTIVITIES);
            if(pi.activities!=null)
            {
            ActivityInfo[] Activities_array = pi.activities;
    
            for (int i = 0; i < Activities_array.length; i++) {
                int j=i+1;
                Activities  = Activities + j + ") "+ pi.activities[i].name+ ", \n";
            }
            }
    
            if(Activities.equals(null))
                return "-";
            else 
                return Activities;
    
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
            return null;
        }
    }`
    

提交回复
热议问题