鸿蒙OS开发文档 鸿蒙OS LauncherShortcutInfo

2024-02-25 开发教程 鸿蒙OS开发文档 匿名 2

LauncherShortcutInfo

java.lang.Object
|---ohos.bundle.LauncherShortcutInfo

public class LauncherShortcutInfo
extends Object

提供有关从主屏幕启动的应用程序的启动器ability的快捷方式的信息。

该类提供了获取快捷方式所属应用程序的快捷方式 ID、图标和包名称的方法。

构造函数摘要

构造函数描述
LauncherShortcutInfo(Context context, ShortcutInfo shortcutInfo)用于创建 LauncherShortcutInfo 实例的构造函数。

方法总结

修饰符和类型方法描述
StringgetBundleName()获取该快捷方式所属的应用程序包名称。
ElementgetIcon()获取该快捷方式的图标。
ListShortcutIntentgetIntents()获取此快捷方式中包含的所有 ShortcutIntent 对象。
StringgetLabel()获取该快捷方式的标签。
StringgetShortcutId()获取此快捷方式的 ID。
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

构造函数详细信息

LauncherShortcutInfo

public LauncherShortcutInfo(Context context, ShortcutInfo shortcutInfo)

用于创建 LauncherShortcutInfo 实例的构造函数。

参数:

参数名称参数描述
context表示快捷方式的上下文对象。
shortcutInfo指示有关快捷方式的信息。

方法详情

getShortcutId

public String getShortcutId()

获取此快捷方式的 ID。

快捷方式 ID 唯一标识快捷方式。

返回:

返回快捷方式 ID。

getBundleName

public String getBundleName()

获取该快捷方式所属的应用程序包名称。

返回:

返回应用程序的包名称。

getLabel

public String getLabel()

获取该快捷方式的标签。

快捷方式的标签是指快捷方式列表中显示的标题。

返回:

返回快捷方式标签。

getIntents

public ListShortcutIntent getIntents()

获取此快捷方式中包含的所有 ShortcutIntent 对象。

ohos.bundle.ShortcutIntent 对象用于导航到快捷方式的目标ability。

返回:

返回此快捷方式中所有 ohos.bundle.ShortcutIntent 对象的列表。

getIcon

public Element getIcon()

获取该快捷方式的图标。

快捷方式图标显示在快捷方式列表中。

返回:

返回快捷方式图标。