鴻蒙OS ShortcutInfo

2022-04-25 17:42 更新

ShortcutInfo

java.lang.Object

|---ohos.bundle.ShortcutInfo

public class ShortcutInfo
extends Object
implements Sequenceable

提供有關(guān)快捷方式的信息,包括快捷方式 ID 和標(biāo)簽。

嵌套類摘要

從接口 ohos.utils.Sequenceable 繼承的嵌套類/接口
Sequenceable.ProducerT

字段摘要

修飾符和類型 字段 描述
static Sequenceable.ProducerShortcutInfo PRODUCER 從 Parcel 創(chuàng)建一個(gè) ShortcutInfo 實(shí)例。

構(gòu)造函數(shù)摘要

構(gòu)造函數(shù) 描述
ShortcutInfo() 用于創(chuàng)建 ShortcutInfo 實(shí)例的默認(rèn)構(gòu)造函數(shù)。
ShortcutInfo(ShortcutInfo source) 用于通過從現(xiàn)有參數(shù)復(fù)制參數(shù)來創(chuàng)建 ShortcutInfo 實(shí)例的構(gòu)造函數(shù)。

方法總結(jié)

修飾符和類型 方法 描述
String getBundleName() 獲取該快捷方式所屬的應(yīng)用程序包名稱。
String getDisableMessage() 獲取此快捷方式的禁用消息。
String getHostAbilityName() 獲取托管此快捷方式的ability的類名。
String getIcon() 獲取該快捷方式的圖標(biāo)路徑。
String getId() 獲取此快捷方式的 ID。
ShortcutIntent getIntent() 獲取此快捷方式的 ShortcutIntent 對象。
ListShortcutIntent getIntents() 獲取此快捷方式中包含的所有 ShortcutIntent 對象。
String getLabel() 獲取該快捷方式的標(biāo)簽。
boolean isEnabled() 檢查是否啟用了此快捷方式。
boolean isHomeShortcut() 檢查此快捷方式是否是主屏幕快捷方式。
boolean isStatic() 檢查此快捷方式是否是靜態(tài)的。
boolean marshalling(Parcel out) 將此 Sequenceable 對象編組為 Parcel。
void setBundleName(String bundleName) 設(shè)置此快捷方式的 bundleName。
void setDisableMessage(String disableMessage) 設(shè)置此快捷方式的禁用消息。
void setHostAbilityName(String hostAbility) 設(shè)置托管此快捷方式的ability的類名。
void setIcon(String icon) 設(shè)置此快捷方式的圖標(biāo)路徑。
void setId(String id) 設(shè)置此快捷方式的 ID。
void setIntent(ShortcutIntent intent) 設(shè)置此快捷方式的 ShortcutIntent。
void setIntents(ListShortcutIntent intents) 為此快捷方式設(shè)置多個(gè)intent。
void setLabel(String label) 設(shè)置此快捷方式的標(biāo)簽。
boolean unmarshalling(Parcel in) 從 Parcel 中解組此 Sequenceable 對象。
從類 java.lang.Object 繼承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
從接口 ohos.utils.Sequenceable 繼承的方法
hasFileDescriptor

字段詳細(xì)信息

PRODUCER

public static final Sequenceable.ProducerShortcutInfo PRODUCER

從 Parcel 創(chuàng)建一個(gè) ShortcutInfo 實(shí)例。

構(gòu)造函數(shù)詳細(xì)信息

ShortcutInfo

public ShortcutInfo()

用于創(chuàng)建 ShortcutInfo 實(shí)例的默認(rèn)構(gòu)造函數(shù)。

ShortcutInfo

public ShortcutInfo(ShortcutInfo source)

用于通過從現(xiàn)有參數(shù)復(fù)制參數(shù)來創(chuàng)建 ShortcutInfo 實(shí)例的構(gòu)造函數(shù)。

參數(shù):

參數(shù)名稱 參數(shù)描述
source 指示 ShortcutInfo 對象。

方法詳情

setId

public void setId(String id)

設(shè)置此快捷方式的 ID。 此方法對靜態(tài)快捷方式無效。

參數(shù):

參數(shù)名稱 參數(shù)描述
id 表示要設(shè)置的快捷方式ID。

getId

public String getId()

獲取此快捷方式的 ID。

快捷方式 ID 唯一標(biāo)識快捷方式。

返回:

返回快捷方式 ID。

setBundleName

public void setBundleName(String bundleName)

設(shè)置此快捷方式的 bundleName。 此方法對靜態(tài)快捷方式無效。

參數(shù):

參數(shù)名稱 參數(shù)描述
bundleName 指示此快捷方式所屬的應(yīng)用程序的捆綁包名稱。

getBundleName

public String getBundleName()

獲取該快捷方式所屬的應(yīng)用程序包名稱。

返回:

返回應(yīng)用程序的包名稱。

setHostAbilityName

public void setHostAbilityName(String hostAbility)

設(shè)置托管此快捷方式的ability的類名。 此方法對靜態(tài)快捷方式無效。

參數(shù):

參數(shù)名稱 參數(shù)描述
hostAbility 指示創(chuàng)建此快捷方式的ability的類名。

getHostAbilityName

public String getHostAbilityName()

獲取托管此快捷方式的ability的類名。

返回:

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

setIcon

public void setIcon(String icon)

設(shè)置此快捷方式的圖標(biāo)路徑。 此方法對靜態(tài)快捷方式無效。

參數(shù):

參數(shù)名稱 參數(shù)描述
icon 表示快捷方式圖標(biāo)的存放路徑。

getIcon

public String getIcon()

獲取該快捷方式的圖標(biāo)路徑。

返回:

返回存儲快捷方式圖標(biāo)的路徑。

setLabel

public void setLabel(String label)

設(shè)置此快捷方式的標(biāo)簽。 此方法對靜態(tài)快捷方式無效。

快捷方式的標(biāo)簽是用戶可見的快捷方式信息。

參數(shù):

參數(shù)名稱 參數(shù)描述
label 指示要設(shè)置的快捷方式標(biāo)簽。

getLabel

public String getLabel()

獲取該快捷方式的標(biāo)簽。

返回:

返回快捷方式標(biāo)簽。

setDisableMessage

public void setDisableMessage(String disableMessage)

設(shè)置此快捷方式的禁用消息。 此方法對靜態(tài)快捷方式無效。

參數(shù):

參數(shù)名稱 參數(shù)描述
disableMessage 指示要設(shè)置的禁用消息。

getDisableMessage

public String getDisableMessage()

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

返回:

返回快捷方式禁用消息。

setIntents

public void setIntents(ListShortcutIntent intents)

為此快捷方式設(shè)置多個(gè)intent。 此方法對靜態(tài)快捷方式無效。

如果為一個(gè)快捷方式設(shè)置了多個(gè)intent,則所有這些 ShortcutIntent 對象中指定的ability將在快捷方式啟動(dòng)時(shí)依次啟動(dòng)。

參數(shù):

參數(shù)名稱 參數(shù)描述
intents 指示要設(shè)置的 ShortcutIntent 對象的列表。

setIntent

public void setIntent(ShortcutIntent intent)

設(shè)置此快捷方式的 ShortcutIntent。 如果多次調(diào)用此方法,則最近一次調(diào)用中設(shè)置的 ShortcutIntent 將覆蓋之前的。 此方法對靜態(tài)快捷方式無效。

參數(shù):

參數(shù)名稱 參數(shù)描述
intent 指示要設(shè)置的 ShortcutIntent 對象。

getIntents

public ListShortcutIntent getIntents()

獲取此快捷方式中包含的所有 ShortcutIntent 對象。

ohos.bundle.ShortcutIntent 對象用于導(dǎo)航到快捷方式的目標(biāo)ability。

返回:

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

getIntent

public ShortcutIntent getIntent()

獲取此快捷方式的 ShortcutIntent 對象。 如果有多個(gè)intent,則返回 ShortcutIntent 列表中的最后一個(gè)。

返回:

返回此快捷方式的 ShortcutIntent 列表中的最后一個(gè)對象。

isStatic

public boolean isStatic()

檢查此快捷方式是否是靜態(tài)的。

返回:

如果此快捷方式是靜態(tài)的,則返回 true; 否則返回 false。

isHomeShortcut

public boolean isHomeShortcut()

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

返回:

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

isEnabled

public boolean isEnabled()

檢查是否啟用了此快捷方式。

返回:

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

marshalling

public boolean marshalling(Parcel out)

從接口復(fù)制的描述:Sequenceable

將此 Sequenceable 對象編組為 Parcel。

指定者:

接口 Sequenceable 中的編組

參數(shù):

參數(shù)名稱 參數(shù)描述
out 指示將 Sequenceable 對象編組到的 Parcel 對象。

返回:

如果編組成功,則返回 true; 否則返回 false。

unmarshalling

public boolean unmarshalling(Parcel in)

從接口復(fù)制的描述:Sequenceable

從 Parcel 中解組此 Sequenceable 對象。

指定者:

在接口 Sequenceable 中解組

參數(shù):

參數(shù)名稱 參數(shù)描述
in 指示已將 Sequenceable 對象編組到的 Parcel 對象。

返回:

如果解組成功,則返回 true; 否則返回 false。

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號