鴻蒙OS NotificationActionButton.Builder

2022-10-11 10:17 更新

NotificationActionButton.Builder

java.lang.Object

|---ohos.event.notification.NotificationActionButton.Builder

public static final class NotificationActionButton.Builder
extends Object

NotificationActionButton 對(duì)象的生成器類(lèi)。

Since:

3

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

構(gòu)造函數(shù) 描述
Builder(NotificationActionButton actionButton) 用于通過(guò)從現(xiàn)有 NotificationActionButton 對(duì)象復(fù)制參數(shù)來(lái)創(chuàng)建 Builder 實(shí)例的構(gòu)造函數(shù)。
Builder(PixelMap icon, String title, IntentAgent intentAgent) 用于創(chuàng)建具有指定圖標(biāo)、標(biāo)題和 IntentAgent 的 Builder 實(shí)例的構(gòu)造函數(shù),用于創(chuàng)建 NotificationActionButton 對(duì)象。

方法總結(jié)

修飾符和類(lèi)型 方法 描述
NotificationActionButton.Builder addAdditionalData(PacMap pacMap) 將附加數(shù)據(jù)添加到此 Builder。
NotificationActionButton.Builder addNotificationUserInput(NotificationUserInput userInput) 添加用于收集用戶輸入的 NotificationUserInput 對(duì)象。
NotificationActionButton build() 使用所有設(shè)置創(chuàng)建一個(gè)新的 NotificationActionButton 對(duì)象。
NotificationActionButton.Builder setAutoCreatedReplies(boolean autoCreatedReplies) 設(shè)置是否允許平臺(tái)自動(dòng)生成可能的回復(fù)并將其添加到 NotificationUserInput#getOptions()。
NotificationActionButton.Builder setContextDependent(boolean isContextual) 設(shè)置此 NotificationActionButton 是否為上下文動(dòng)作,即此 NotificationActionButton 是否依賴(lài)于通知消息體。
NotificationActionButton.Builder setSemanticActionButton(NotificationConstant.SemanticActionButton semanticActionButton) 為此 NotificationActionButton 設(shè)置語(yǔ)義操作。
從類(lèi) java.lang.Object 繼承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

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

Builder

public Builder(PixelMap icon, String title, IntentAgent intentAgent)

用于創(chuàng)建具有指定圖標(biāo)、標(biāo)題和 IntentAgent 的 Builder 實(shí)例的構(gòu)造函數(shù),用于創(chuàng)建 NotificationActionButton 對(duì)象。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
icon 指示表示此 NotificationActionButton 的圖標(biāo)。
title 指示此 NotificationActionButton 的標(biāo)題。
intentAgent 指示觸發(fā)此 NotificationActionButton 時(shí)要觸發(fā)的 IntentAgent。

Since:

3

Builder

public Builder(NotificationActionButton actionButton)

用于通過(guò)從現(xiàn)有 NotificationActionButton 對(duì)象復(fù)制參數(shù)來(lái)創(chuàng)建 Builder 實(shí)例的構(gòu)造函數(shù)。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
actionButton 指示現(xiàn)有的 NotificationActionButton 對(duì)象。

Since:

3

方法詳情

addNotificationUserInput

public NotificationActionButton.Builder addNotificationUserInput(NotificationUserInput userInput)

添加用于收集用戶輸入的 NotificationUserInput 對(duì)象。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
userInput 指示要添加的 NotificationUserInput 對(duì)象。

返回:

返回此 Builder 對(duì)象。

Since:

3

setContextDependent

public NotificationActionButton.Builder setContextDependent(boolean isContextual)

設(shè)置此 NotificationActionButton 是否為上下文動(dòng)作,即此 NotificationActionButton 是否依賴(lài)于通知消息體。 例如,上下文 NotificationActionButton 在通知中為用戶打開(kāi)地圖應(yīng)用程序提供地址。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
isContextual 指定此 NotificationActionButton 是否為上下文操作。 值 true 表示上下文操作,值 false 表示不是。

返回:

返回此 Builder 對(duì)象。

Since:

3

setSemanticActionButton

public NotificationActionButton.Builder setSemanticActionButton(NotificationConstant.SemanticActionButton semanticActionButton)

為此 NotificationActionButton 設(shè)置語(yǔ)義操作。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
semanticActionButton 表示要添加的語(yǔ)義動(dòng)作。 有關(guān)可用值,請(qǐng)參閱 NotificationConstant.SemanticActionButton。

返回:

返回此 Builder 對(duì)象。

Since:

3

setAutoCreatedReplies

public NotificationActionButton.Builder setAutoCreatedReplies(boolean autoCreatedReplies)

設(shè)置是否允許平臺(tái)自動(dòng)生成可能的回復(fù)并將其添加到 NotificationUserInput#getOptions()。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
autoCreatedReplies 指定是否允許平臺(tái)自動(dòng)生成可能的回復(fù)。 值 true 表示允許生成回復(fù); 值 false 表示不是。

返回:

返回此 Builder 對(duì)象。

Since:

3

addAdditionalData

public NotificationActionButton.Builder addAdditionalData(PacMap pacMap)

將附加數(shù)據(jù)添加到此 Builder。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
pacMap 指示包含附加數(shù)據(jù)的 PacMap 對(duì)象。

返回:

返回此 Builder 對(duì)象。

Since:

3

build

public NotificationActionButton build()

使用所有設(shè)置創(chuàng)建一個(gè)新的 NotificationActionButton 對(duì)象。

返回:

返回創(chuàng)建的 NotificationActionButton 對(duì)象。

Throws:

Throw名稱(chēng) Throw描述
IllegalArgumentException 如果 NotificationActionButton.isContextDependent() 為 true 但 icon 或 intentAgent 為 null,則引發(fā)此異常。

Since:

3

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

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)