Most visited

Recently visited

Added in API level 21

LauncherApps

public class LauncherApps
extends Object

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


用于检索当前用户和任何关联的托管配置文件的可启动活动列表的类。 这主要是供发射器使用的。 应用程序可以查询每个用户配置文件。 由于PackageManager不会为其他配置文件传送包裹广播,因此您可以在此注册包裹更改。

要监视正在添加或删除的托管配置文件,请注册以下广播: ACTION_MANAGED_PROFILE_ADDEDACTION_MANAGED_PROFILE_REMOVED

您可以使用 getUserProfiles()检索与此用户关联的配置文件列表。

Summary

Nested classes

class LauncherApps.Callback

对此包和相关托管配置文件进行软件包更改的回调。

Public methods

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

为指定用户检索匹配 ACTION_MAINCATEGORY_LAUNCHER的可启动活动的列表。

boolean isActivityEnabled(ComponentName component, UserHandle user)

检查活动是否存在,并为配置文件启用。

boolean isPackageEnabled(String packageName, UserHandle user)

检查包是否已安装并启用了配置文件。

void registerCallback(LauncherApps.Callback callback, Handler handler)

为当前和托管配置文件中的包的更改注册回调。

void registerCallback(LauncherApps.Callback callback)

为当前和托管配置文件中的包的更改注册回调。

LauncherActivityInfo resolveActivity(Intent intent, UserHandle user)

返回给定意图和用户句柄的活动信息,如果它解决。

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

启动设置活动以显示指定配置文件中软件包的应用程序详细信息。

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

在指定的配置文件中开始主要活动。

void unregisterCallback(LauncherApps.Callback callback)

取消注册之前注册的回调。

Inherited methods

From class java.lang.Object

Public methods

getActivityList

Added in API level 21
List<LauncherActivityInfo> getActivityList (String packageName, 
                UserHandle user)

为指定用户检索与 ACTION_MAINCATEGORY_LAUNCHER匹配的可启动活动的列表。

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.

isActivityEnabled

Added in API level 21
boolean isActivityEnabled (ComponentName component, 
                UserHandle user)

检查活动是否存在,并为配置文件启用。

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

isPackageEnabled

Added in API level 21
boolean isPackageEnabled (String packageName, 
                UserHandle user)

检查包是否已安装并启用了配置文件。

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

registerCallback

Added in API level 21
void registerCallback (LauncherApps.Callback callback, 
                Handler handler)

为当前和托管配置文件中的包的更改注册回调。

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

registerCallback

Added in API level 21
void registerCallback (LauncherApps.Callback callback)

为当前和托管配置文件中的包的更改注册回调。

Parameters
callback LauncherApps.Callback: The callback to register.

resolveActivity

Added in API level 21
LauncherActivityInfo resolveActivity (Intent intent, 
                UserHandle user)

返回给定意图和用户句柄的活动信息,如果它解决。 否则它返回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.

startAppDetailsActivity

Added in API level 21
void startAppDetailsActivity (ComponentName component, 
                UserHandle user, 
                Rect sourceBounds, 
                Bundle opts)

启动设置活动以显示指定配置文件中软件包的应用程序详细信息。

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

startMainActivity

Added in API level 21
void startMainActivity (ComponentName component, 
                UserHandle user, 
                Rect sourceBounds, 
                Bundle opts)

在指定的配置文件中开始主要活动。

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

unregisterCallback

Added in API level 21
void unregisterCallback (LauncherApps.Callback callback)

取消注册之前注册的回调。

Parameters
callback LauncherApps.Callback: The callback to unregister.

也可以看看:

Hooray!