阅读(3732) (0)

鸿蒙OS ShortcutInfo

2022-04-21 16:25:08 更新

ShortcutInfo

java.lang.Object

|---ohos.bundle.ShortcutInfo

public class ShortcutInfo
extends Object
implements Sequenceable

提供有关快捷方式的信息,包括快捷方式 ID 和标签。

嵌套类摘要

从接口 ohos.utils.Sequenceable 继承的嵌套类/接口
Sequenceable.ProducerT

字段摘要

修饰符和类型 字段 描述
static Sequenceable.ProducerShortcutInfo PRODUCER 从 Parcel 创建一个 ShortcutInfo 实例。

构造函数摘要

构造函数 描述
ShortcutInfo() 用于创建 ShortcutInfo 实例的默认构造函数。
ShortcutInfo(ShortcutInfo source) 用于通过从现有参数复制参数来创建 ShortcutInfo 实例的构造函数。

方法总结

修饰符和类型 方法 描述
String getBundleName() 获取该快捷方式所属的应用程序包名称。
String getDisableMessage() 获取此快捷方式的禁用消息。
String getHostAbilityName() 获取托管此快捷方式的ability的类名。
String getIcon() 获取该快捷方式的图标路径。
String getId() 获取此快捷方式的 ID。
ShortcutIntent getIntent() 获取此快捷方式的 ShortcutIntent 对象。
ListShortcutIntent getIntents() 获取此快捷方式中包含的所有 ShortcutIntent 对象。
String getLabel() 获取该快捷方式的标签。
boolean isEnabled() 检查是否启用了此快捷方式。
boolean isHomeShortcut() 检查此快捷方式是否是主屏幕快捷方式。
boolean isStatic() 检查此快捷方式是否是静态的。
boolean marshalling(Parcel out) 将此 Sequenceable 对象编组为 Parcel。
void setBundleName(String bundleName) 设置此快捷方式的 bundleName。
void setDisableMessage(String disableMessage) 设置此快捷方式的禁用消息。
void setHostAbilityName(String hostAbility) 设置托管此快捷方式的ability的类名。
void setIcon(String icon) 设置此快捷方式的图标路径。
void setId(String id) 设置此快捷方式的 ID。
void setIntent(ShortcutIntent intent) 设置此快捷方式的 ShortcutIntent。
void setIntents(ListShortcutIntent intents) 为此快捷方式设置多个intent。
void setLabel(String label) 设置此快捷方式的标签。
boolean unmarshalling(Parcel in) 从 Parcel 中解组此 Sequenceable 对象。
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口 ohos.utils.Sequenceable 继承的方法
hasFileDescriptor

字段详细信息

PRODUCER

public static final Sequenceable.ProducerShortcutInfo PRODUCER

从 Parcel 创建一个 ShortcutInfo 实例。

构造函数详细信息

ShortcutInfo

public ShortcutInfo()

用于创建 ShortcutInfo 实例的默认构造函数。

ShortcutInfo

public ShortcutInfo(ShortcutInfo source)

用于通过从现有参数复制参数来创建 ShortcutInfo 实例的构造函数。

参数:

参数名称 参数描述
source 指示 ShortcutInfo 对象。

方法详情

setId

public void setId(String id)

设置此快捷方式的 ID。 此方法对静态快捷方式无效。

参数:

参数名称 参数描述
id 表示要设置的快捷方式ID。

getId

public String getId()

获取此快捷方式的 ID。

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

返回:

返回快捷方式 ID。

setBundleName

public void setBundleName(String bundleName)

设置此快捷方式的 bundleName。 此方法对静态快捷方式无效。

参数:

参数名称 参数描述
bundleName 指示此快捷方式所属的应用程序的捆绑包名称。

getBundleName

public String getBundleName()

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

返回:

返回应用程序的包名称。

setHostAbilityName

public void setHostAbilityName(String hostAbility)

设置托管此快捷方式的ability的类名。 此方法对静态快捷方式无效。

参数:

参数名称 参数描述
hostAbility 指示创建此快捷方式的ability的类名。

getHostAbilityName

public String getHostAbilityName()

获取托管此快捷方式的ability的类名。

返回:

返回此快捷方式的宿主ability的类名。

setIcon

public void setIcon(String icon)

设置此快捷方式的图标路径。 此方法对静态快捷方式无效。

参数:

参数名称 参数描述
icon 表示快捷方式图标的存放路径。

getIcon

public String getIcon()

获取该快捷方式的图标路径。

返回:

返回存储快捷方式图标的路径。

setLabel

public void setLabel(String label)

设置此快捷方式的标签。 此方法对静态快捷方式无效。

快捷方式的标签是用户可见的快捷方式信息。

参数:

参数名称 参数描述
label 指示要设置的快捷方式标签。

getLabel

public String getLabel()

获取该快捷方式的标签。

返回:

返回快捷方式标签。

setDisableMessage

public void setDisableMessage(String disableMessage)

设置此快捷方式的禁用消息。 此方法对静态快捷方式无效。

参数:

参数名称 参数描述
disableMessage 指示要设置的禁用消息。

getDisableMessage

public String getDisableMessage()

获取此快捷方式的禁用消息。

返回:

返回快捷方式禁用消息。

setIntents

public void setIntents(ListShortcutIntent intents)

为此快捷方式设置多个intent。 此方法对静态快捷方式无效。

如果为一个快捷方式设置了多个intent,则所有这些 ShortcutIntent 对象中指定的ability将在快捷方式启动时依次启动。

参数:

参数名称 参数描述
intents 指示要设置的 ShortcutIntent 对象的列表。

setIntent

public void setIntent(ShortcutIntent intent)

设置此快捷方式的 ShortcutIntent。 如果多次调用此方法,则最近一次调用中设置的 ShortcutIntent 将覆盖之前的。 此方法对静态快捷方式无效。

参数:

参数名称 参数描述
intent 指示要设置的 ShortcutIntent 对象。

getIntents

public ListShortcutIntent getIntents()

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

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

返回:

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

getIntent

public ShortcutIntent getIntent()

获取此快捷方式的 ShortcutIntent 对象。 如果有多个intent,则返回 ShortcutIntent 列表中的最后一个。

返回:

返回此快捷方式的 ShortcutIntent 列表中的最后一个对象。

isStatic

public boolean isStatic()

检查此快捷方式是否是静态的。

返回:

如果此快捷方式是静态的,则返回 true; 否则返回 false。

isHomeShortcut

public boolean isHomeShortcut()

检查此快捷方式是否是主屏幕快捷方式。

返回:

如果此快捷方式是主屏幕快捷方式,则返回 true; 否则返回 false。

isEnabled

public boolean isEnabled()

检查是否启用了此快捷方式。

返回:

如果启用此快捷方式,则返回 true; 否则返回 false。

marshalling

public boolean marshalling(Parcel out)

从接口复制的描述:Sequenceable

将此 Sequenceable 对象编组为 Parcel。

指定者:

接口 Sequenceable 中的编组

参数:

参数名称 参数描述
out 指示将 Sequenceable 对象编组到的 Parcel 对象。

返回:

如果编组成功,则返回 true; 否则返回 false。

unmarshalling

public boolean unmarshalling(Parcel in)

从接口复制的描述:Sequenceable

从 Parcel 中解组此 Sequenceable 对象。

指定者:

在接口 Sequenceable 中解组

参数:

参数名称 参数描述
in 指示已将 Sequenceable 对象编组到的 Parcel 对象。

返回:

如果解组成功,则返回 true; 否则返回 false。