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
class LauncherApps.Callback Callbacks for package changes to this and related managed profiles. 
Public Methods
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 isActivityEnabled(ComponentName component, UserHandle user)
Checks if the activity exists and it enabled for a profile.
boolean isPackageEnabled(String packageName, UserHandle user)
Checks if the package is installed and enabled for a profile.
void registerCallback(LauncherApps.Callback callback)
Registers a callback for changes to packages in current and managed profiles.
void registerCallback(LauncherApps.Callback callback, Handler handler)
Registers a callback for changes to packages in current and managed profiles.
LauncherActivityInfo resolveActivity(Intent intent, UserHandle user)
Returns the activity info for a given intent and user handle, if it resolves.
void startAppDetailsActivity(ComponentName component, UserHandle user, Rect sourceBounds, Bundle opts)
Starts the settings activity to show the application details for a package in the specified profile.
void startMainActivity(ComponentName component, UserHandle user, Rect sourceBounds, Bundle opts)
Starts a Main activity in the specified profile.
void unregisterCallback(LauncherApps.Callback callback)
Unregisters a callback that was previously registered.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

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

Added in API level 21

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 isActivityEnabled (ComponentName component, UserHandle user)

Added in API level 21

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 isPackageEnabled (String packageName, UserHandle user)

Added in API level 21

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 registerCallback (LauncherApps.Callback callback)

Added in API level 21

Registers a callback for changes to packages in current and managed profiles.

Parameters
callback The callback to register.

public void registerCallback (LauncherApps.Callback callback, Handler handler)

Added in API level 21

Registers a callback for changes to packages in current and managed profiles.

Parameters
callback The callback to register.
handler that should be used to post callbacks on, may be null.

public LauncherActivityInfo resolveActivity (Intent intent, UserHandle user)

Added in API level 21

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 startAppDetailsActivity (ComponentName component, UserHandle user, Rect sourceBounds, Bundle opts)

Added in API level 21

Starts the settings activity to show the application details for a package in the specified profile.

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

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

Added in API level 21

Starts a Main 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

public void unregisterCallback (LauncherApps.Callback callback)

Added in API level 21

Unregisters a callback that was previously registered.

Parameters
callback The callback to unregister.