获取Android应用程序的启动活动名称

获取Android应用程序的启动活动名称

问题描述:

我需要发射活动的名称,从我的应用程序启动活动。 任何解决方案

I need to get the name of launcher activity to launch the activity from my application. Any solution

使用下面的code让所有包的发射活动:

Use the following code to get the launcher activity of all packages:

final PackageManager pm = getPackageManager();

        Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
        mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);

        List<ResolveInfo> appList = pm.queryIntentActivities(mainIntent, 0);
        Collections.sort(appList, new ResolveInfo.DisplayNameComparator(pm));

        for (ResolveInfo temp : appList) {

            Log.v("my logs", "package and activity name = "
                    + temp.activityInfo.packageName + "    "
                    + temp.activityInfo.name);


        }