public
class
LauncherApps
extends Object
java.lang.Object | |
↳ | android.content.pm.LauncherApps |
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()
.
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 |
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, Handler handler)
Registers a callback for changes to packages in current and managed profiles. |
void
|
registerCallback(LauncherApps.Callback callback)
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. |
Inherited methods | |
---|---|
From
class
java.lang.Object
|
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 |
String :
The specific package to query. If null, it checks all installed packages
in the profile. |
user |
UserHandle :
The UserHandle of the profile. |
Returns | |
---|---|
List<LauncherActivityInfo> |
List of launchable activities. Can be an empty list but will not be null. |
boolean isActivityEnabled (ComponentName component, UserHandle user)
Checks if the activity exists and it enabled for a profile.
Parameters | |
---|---|
component |
ComponentName :
The activity to check. |
user |
UserHandle :
The UserHandle of the profile. |
Returns | |
---|---|
boolean |
true if the activity exists and is enabled. |
boolean isPackageEnabled (String packageName, UserHandle user)
Checks if the package is installed and enabled for a profile.
Parameters | |
---|---|
packageName |
String :
The package to check. |
user |
UserHandle :
The UserHandle of the profile. |
Returns | |
---|---|
boolean |
true if the package exists and is enabled. |
void registerCallback (LauncherApps.Callback callback, Handler handler)
Registers a callback for changes to packages in current and managed profiles.
Parameters | |
---|---|
callback |
LauncherApps.Callback :
The callback to register. |
handler |
Handler :
that should be used to post callbacks on, may be null.
|
void registerCallback (LauncherApps.Callback callback)
Registers a callback for changes to packages in current and managed profiles.
Parameters | |
---|---|
callback |
LauncherApps.Callback :
The callback to register.
|
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 |
Intent :
The intent to find a match for. |
user |
UserHandle :
The profile to look in for a match. |
Returns | |
---|---|
LauncherActivityInfo |
An activity info object if there is a match. |
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.
Parameters | |
---|---|
component |
ComponentName :
The ComponentName of the package to launch settings for. |
user |
UserHandle :
The UserHandle of the profile |
sourceBounds |
Rect :
The Rect containing the source bounds of the clicked icon |
opts |
Bundle :
Options to pass to startActivity
|
void startMainActivity (ComponentName component, UserHandle user, Rect sourceBounds, Bundle opts)
Starts a Main activity in the specified profile.
Parameters | |
---|---|
component |
ComponentName :
The ComponentName of the activity to launch |
user |
UserHandle :
The UserHandle of the profile |
sourceBounds |
Rect :
The Rect containing the source bounds of the clicked icon |
opts |
Bundle :
Options to pass to startActivity
|
void unregisterCallback (LauncherApps.Callback callback)
Unregisters a callback that was previously registered.
Parameters | |
---|---|
callback |
LauncherApps.Callback :
The callback to unregister. |
See also: