2

I need to check if an installed app has a specific launcher activity class (based on the package name of the app).

I can get the list of activities and find the correct class with this:

PackageInfo info = context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);

for (ActivityInfo a : info.activities) {
    if (a.name.compareTo("specific class name") == 0)

        // if a is launcher activity
            return true;
    }

But I can't seem to find any way to check if the activity is actually the launcher.

Is there any way to get the information about the intent filters associated with the activity from the manifest file?

Diana
  • 75
  • 1
  • 9
  • 1
    possible duplicate of [Get the launcher Activity name of an android application](http://stackoverflow.com/questions/13027374/get-the-launcher-activity-name-of-an-android-application) – Steve Benett Aug 09 '14 at 15:41
  • 1
    I am aware of that solution, I was just wondering if it was possible to achieve this _without_ having to collect all Intents, as it seems a bit much for checking just one app... – Diana Aug 09 '14 at 18:44

2 Answers2

2

Get the list of launcher activity from all apps like below

        final PackageManager pm = getPackageManager();
        // package manager is provider of all the application information
        Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
        mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);

        List<ResolveInfo> appList = pm.queryIntentActivities(mainIntent, 0);

        for (ResolveInfo info : appList) {

            Log.d("package and activity name = "
                    + info.activityInfo.packageName + "    "
                    + info.activityInfo.name);


        }
2

You can check if an app has a launcher activity using this:

(context.packageManager.getLaunchIntentForPackage(app_package_name) != null)