Android APIs
public class

LauncherApps

extends Object
java.lang.Object
   ↳ android.content.pm.LauncherApps

Class Overview

Class for retrieving a list of launchable activities for the current user and any associated managed profiles. This is mainly for use by launchers. Apps can be queried for each user profile. Since the PackageManager will not deliver package broadcasts for other profiles, you can register for package changes here.

To watch for managed profiles being added or removed, register for the following broadcasts: ACTION_MANAGED_PROFILE_ADDED and ACTION_MANAGED_PROFILE_REMOVED.

You can retrieve the list of profiles associated with this user with getUserProfiles().

Summary

Nested Classes
interface LauncherApps.OnAppsChangedListener Callbacks for package changes to this and related managed profiles. 
Public Methods
void addOnAppsChangedListener(LauncherApps.OnAppsChangedListener listener)
Adds a listener for changes to packages in current and managed profiles.
List<LauncherActivityInfo> getActivityList(String packageName, UserHandle user)
Retrieves a list of launchable activities that match ACTION_MAIN and CATEGORY_LAUNCHER, for a specified user.
boolean isActivityEnabledForProfile(ComponentName component, UserHandle user)
Checks if the activity exists and it enabled for a profile.
boolean isPackageEnabledForProfile(String packageName, UserHandle user)
Checks if the package is installed and enabled for a profile.
void removeOnAppsChangedListener(LauncherApps.OnAppsChangedListener listener)
Removes a listener that was previously added.
LauncherActivityInfo resolveActivity(Intent intent, UserHandle user)
Returns the activity info for a given intent and user handle, if it resolves.
void startActivityForProfile(ComponentName component, UserHandle user, Rect sourceBounds, Bundle opts)
Starts an activity in the specified profile.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public void addOnAppsChangedListener (LauncherApps.OnAppsChangedListener listener)

Adds a listener for changes to packages in current and managed profiles.

Parameters
listener The listener to add.

public List<LauncherActivityInfo> getActivityList (String packageName, UserHandle user)

Retrieves a list of launchable activities that match ACTION_MAIN and CATEGORY_LAUNCHER, for a specified user.

Parameters
packageName The specific package to query. If null, it checks all installed packages in the profile.
user The UserHandle of the profile.
Returns
  • List of launchable activities. Can be an empty list but will not be null.

public boolean isActivityEnabledForProfile (ComponentName component, UserHandle user)

Checks if the activity exists and it enabled for a profile.

Parameters
component The activity to check.
user The UserHandle of the profile.
Returns
  • true if the activity exists and is enabled.

public boolean isPackageEnabledForProfile (String packageName, UserHandle user)

Checks if the package is installed and enabled for a profile.

Parameters
packageName The package to check.
user The UserHandle of the profile.
Returns
  • true if the package exists and is enabled.

public void removeOnAppsChangedListener (LauncherApps.OnAppsChangedListener listener)

Removes a listener that was previously added.

Parameters
listener The listener to remove.

public LauncherActivityInfo resolveActivity (Intent intent, UserHandle user)

Returns the activity info for a given intent and user handle, if it resolves. Otherwise it returns null.

Parameters
intent The intent to find a match for.
user The profile to look in for a match.
Returns
  • An activity info object if there is a match.

public void startActivityForProfile (ComponentName component, UserHandle user, Rect sourceBounds, Bundle opts)

Starts an activity in the specified profile.

Parameters
component The ComponentName of the activity to launch
user The UserHandle of the profile
sourceBounds The Rect containing the source bounds of the clicked icon
opts Options to pass to startActivity