W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
java.lang.Object
|---ohos.event.notification.NotificationRequest
public final class NotificationRequest
extends Object
implements Sequenceable
攜帶通知。
在通知發(fā)布方面,需要分別調(diào)用 setContent(ohos.event.notification.NotificationRequest.NotificationContent) 方法指定通知內(nèi)容,調(diào)用 setDeliveryTime(long) 方法設(shè)置通知的發(fā)送時間。 NotificationRequest 在 NotificationHelper#publishNotification(NotificationRequest) 方法中用作輸入?yún)?shù)以發(fā)布通知。 在通知訂閱方面,可以繼承 NotificationSubscriber 類,重寫回調(diào)方法 NotificationSubscriber#onConsumed(NotificationRequest) 和 NotificationSubscriber#onCanceled(NotificationRequest)。 接收或刪除的通知可以存儲在 NotificationRequest 對象中。
Since:
1
修飾符和類型 | 類 | 描述 |
---|---|---|
static class | NotificationRequest.NotificationContent | 設(shè)置要傳遞給 NotificationRequest#setContent(NotificationRequest.NotificationContent) 方法的通知內(nèi)容。 |
static class | NotificationRequest.NotificationConversationalContent | 構(gòu)造一個類似對話的通知,其中包括多個用戶之間的消息通信。 |
static class | NotificationRequest.NotificationLongTextContent | 構(gòu)造包含長文本的通知。 |
static class | NotificationRequest.NotificationMediaContent | 構(gòu)造一個可以與關(guān)聯(lián)的音頻會話交互的媒體播放通知。 |
static class | NotificationRequest.NotificationMultiLineContent | 構(gòu)造一個包含多行文本的通知。 |
static class | NotificationRequest.NotificationNormalContent | 構(gòu)造基本通知。 |
static class | NotificationRequest.NotificationPictureContent | 構(gòu)造包含圖片附件的通知。 |
從接口 ohos.utils.Sequenceable 繼承的嵌套類/接口 |
---|
Sequenceable.ProducerT |
修飾符和類型 | 字段 | 描述 |
---|---|---|
static int | BADGE_STYLE_BIG | 表示此通知的標(biāo)記顯示為大圖標(biāo)。 |
static int | BADGE_STYLE_LITTLE | 表示此通知的標(biāo)記顯示為一個小圖標(biāo)。 |
static int | BADGE_STYLE_NONE | 表示此通知的標(biāo)記僅顯示數(shù)字。 |
static String | CLASSIFICATION_ALARM | 指示警報或定時器的通知分類。 |
static String | CLASSIFICATION_CALL | 指示傳入呼叫或類似同步通信請求的通知分類。 |
static String | CLASSIFICATION_EMAIL | 指示電子郵件通知的分類。 |
static String | CLASSIFICATION_ERROR | 指示在后臺操作或身份驗證過程中發(fā)生的錯誤通知的分類。 |
static String | CLASSIFICATION_EVENT | 指示日歷事件的通知分類。 |
static String | CLASSIFICATION_MESSAGE | 指示短消息或即時消息的通知分類。 |
static String | CLASSIFICATION_NAVIGATION | 表示地圖導(dǎo)航通知的分類。 |
static String | CLASSIFICATION_PROGRESS | 表示長時間在后臺運行的進程的通知分類。 |
static String | CLASSIFICATION_PROMO | 表示廣告或促銷信息通知的分類。 |
static String | CLASSIFICATION_RECOMMENDATION | 指示特定交易的具體及時建議的通知分類。 |
static String | CLASSIFICATION_REMINDER | 指示用戶先前設(shè)置的提醒的通知分類。 |
static String | CLASSIFICATION_SERVICE | 指示正在進行的后臺服務(wù)的通知分類。 |
static String | CLASSIFICATION_SOCIAL | 指示社交網(wǎng)絡(luò)或共享更新通知的分類。 |
static String | CLASSIFICATION_STATUS | 指示有關(guān)設(shè)備和上下文狀態(tài)的持續(xù)信息的通知分類。 |
static String | CLASSIFICATION_SYSTEM | 指示系統(tǒng)或設(shè)備狀態(tài)更新通知的分類。 |
static String | CLASSIFICATION_TRANSPORT | 表示播放過程中媒體傳輸控制的通知分類。 |
static int | COLOR_DEFAULT | 表示默認(rèn)通知背景顏色,即不顯示顏色。 |
static String | EXTRA_USER_INPUT_HISTORY | getAdditionalData() 鍵:這是用戶輸入歷史記錄,提供給 setNotificationUserInputHistory(java.util.List)。 |
static int | GROUP_ALERT_TYPE_ALL | 通知組警報類型,如果為關(guān)聯(lián)的 NotificationSlot 對象啟用聲音或振動,則指示組中的所有通知都有聲音或振動。 |
static int | GROUP_ALERT_TYPE_CHILD | 通知組警報類型,指示子通知有聲音或振動,但如果為關(guān)聯(lián)的 NotificationSlot 對象啟用聲音或振動,則組中的概覽通知會靜音(無聲音或振動)。 |
static int | GROUP_ALERT_TYPE_OVERVIEW | 通知組警報類型,指示概覽通知有聲音或振動,但如果為關(guān)聯(lián)的 NotificationSlot 對象啟用聲音或振動,則組中的子通知將靜音(無聲音或振動)。 |
static Sequenceable.ProducerNotificationRequest | PRODUCER | 從 Parcel 創(chuàng)建 NotificationRequest 實例。 |
static int | VISIBLENESS_TYPE_NO_OVERRIDE | 表示未通過setVisibleness(int)設(shè)置通知顯示效果。 |
static int | VISIBLENESS_TYPE_PRIVATE | 表示鎖屏上只顯示應(yīng)用程序圖標(biāo)、應(yīng)用程序名稱等基本信息。 |
static int | VISIBLENESS_TYPE_PUBLIC | 表示通知的內(nèi)容顯示在鎖定屏幕上。 |
static int | VISIBLENESS_TYPE_SECRET | 表示通知不顯示在鎖定屏幕上。 |
構(gòu)造函數(shù) | 描述 |
---|---|
NotificationRequest() | 用于創(chuàng)建 NotificationRequest 實例的默認(rèn)構(gòu)造函數(shù)。 |
NotificationRequest(int notificationId) | 一個構(gòu)造函數(shù),用于創(chuàng)建一個 NotificationRequest 實例,并傳遞了輸入?yún)?shù) notificationId。 |
NotificationRequest(Context context, int notificationId) | 用于根據(jù)指定的上下文和通知 ID 創(chuàng)建 NotificationRequest 實例的構(gòu)造函數(shù)。 |
NotificationRequest(NotificationRequest request) | 用于通過從現(xiàn)有參數(shù)復(fù)制參數(shù)來創(chuàng)建 NotificationRequest 實例的構(gòu)造函數(shù)。 |
修飾符和類型 | 方法 | 描述 |
---|---|---|
NotificationRequest | addActionButton(NotificationActionButton actionButton) | 向此通知添加 NotificationActionButton。 |
NotificationRequest | addMessageUser(MessageUser messageUser) | 添加一個 MessageUser 對象并將其與此通知相關(guān)聯(lián)。 |
ListNotificationActionButton | getActionButtons() | 獲取包含在此通知中的所有 NotificationActionButton 對象的列表。 |
IntentParams | getAdditionalData() | 獲取通知中設(shè)置的 IntentParams 對象。 |
long | getAutoDeletedTime() | 獲取通知被刪除的時間。 |
int | getBadgeIconStyle() | 獲取該通知的徽章圖標(biāo)樣式。 |
int | getBadgeNumber() | 獲取要為此通知顯示的編號。 |
PixelMap | getBigIcon() | 獲取該通知的大圖標(biāo)。 |
String | getClassification() | 獲取此通知的分類。 |
int | getColor() | 獲取此通知的背景顏色。 |
NotificationRequest.NotificationContent | getContent() | 調(diào)用setContent(ohos.event.notification.NotificationRequest.NotificationContent)方法獲取通知內(nèi)容集。 |
long | getCreateTime() | 已棄用。 此更改從 API 版本 2 開始生效。初始化 NotificationRequest 的時間對公眾是不可訪問的。 要獲取發(fā)送通知的時間,請調(diào)用 getDeliveryTime() 方法。 |
String | getCreatorBundleName() | 獲取通知創(chuàng)建者的包名。 |
int | getCreatorPid() | 獲取通知創(chuàng)建者的PID。 |
int | getCreatorUid() | 獲取通知創(chuàng)建者的 UID。 |
ComponentProvider | getCustomBigView() | 獲取定義此通知展開時要顯示的自定義視圖的 ComponentProvider 對象。 |
ComponentProvider | getCustomFloatView() | 獲取定義當(dāng)此通知顯示為屏幕頂部的浮動窗口時要顯示的自定義視圖的 ComponentProvider 對象。 |
ComponentProvider | getCustomView() | 獲取定義此通知中設(shè)置的自定義視圖的 ComponentProvider 對象。 |
long | getDeliveryTime() | 獲取通知下發(fā)的時間。 |
int | getGroupAlertType() | 獲取該通知的群組告警類型。 |
String | getGroupValue() | 獲取本次通知的組信息。 |
IntentAgent | getIntentAgent() | 獲取此通知中包含的 IntentAgent。 |
String | getLabel() | 獲取此通知的標(biāo)簽。 |
PixelMap | getLittleIcon() | 獲取通知的圖標(biāo)。 |
IntentAgent | getMaxScreenIntentAgent() | 調(diào)用setMaxScreenIntentAgent(ohos.event.intentagent.IntentAgent)獲取全屏IntentAgent集合。 |
ListMessageUser | getMessageUsers() | 獲取與此通知關(guān)聯(lián)的所有 MessageUser 對象。 |
String | getNotificationHashCode() | 獲取當(dāng)前應(yīng)用中通知的唯一哈希碼。 |
int | getNotificationId() | 獲取通知ID,在當(dāng)前應(yīng)用中是唯一的。 |
int | getNotificationType() | 獲取通知類型。 |
String | getOwnerBundleName() | 獲取通知所有者的捆綁包名稱。 |
int | getProgressMax() | 獲取此通知的進度條顯示的最大值。 |
int | getProgressValue() | 獲取此通知的進度條顯示的當(dāng)前值。 |
IntentAgent | getRemovalIntentAgent() | 獲取用戶顯式移除此通知時觸發(fā)的 IntentAgent 對象。 |
String | getSettingsText() | 獲取將顯示為應(yīng)用程序設(shè)置鏈接的文本。 |
String | getShortcutId() | 獲取與此通知關(guān)聯(lián)的快捷方式 ID。 |
String | getSlotId() | 通過調(diào)用setSlotId(java.lang.String)方法獲取通知集的槽位ID。 |
String | getSortingKey() | 獲取用于對來自同一應(yīng)用程序包的通知進行排序的密鑰。 |
String | getStatusBarText() | 獲取收到此通知時將在狀態(tài)欄中顯示的滾動文本。 |
int | getVisibleness() | 獲取該通知在鎖屏?xí)r的顯示效果。 |
boolean | isAlertOneTime() | 檢查此通知是否設(shè)置為僅提醒一次,這意味著在更新具有相同 ID 的通知時將不再播放聲音或振動。 |
boolean | isColorEnabled() | 檢查是否為此通知啟用了背景顏色。 |
boolean | isCountdownTimer() | 檢查通知創(chuàng)建時間是否顯示為倒計時。 |
boolean | isFloatingIcon() | 檢查此通知是否顯示為屏幕頂部的浮動圖標(biāo)。 |
boolean | isGroupOverview() | 檢查此通知是否為組概覽。 |
boolean | isInProgress() | 檢查此通知是否正在進行中。 |
boolean | isOnlyLocal() | 檢查此通知是否僅與本地設(shè)備相關(guān),不能在遠程設(shè)備上顯示。 |
boolean | isPermitSystemGeneratedContextualActionButtons() | 檢查是否允許平臺為此通知生成上下文 NotificationActionButton 對象。檢查是否允許平臺為此通知生成上下文 NotificationActionButton 對象。 |
boolean | isProgressIndeterminate() | 檢查此通知的進度條是否不確定。 |
boolean | isShowCreateTime() | 已棄用。 此更改從 API 版本 2 開始生效。請改用 isShowDeliveryTime()。 通知顯示它的發(fā)送時間,而不是它的創(chuàng)建時間。 |
boolean | isShowDeliveryTime() | 檢查是否顯示此通知的通知傳遞時間。 |
boolean | isShowStopwatch() | 檢查通知創(chuàng)建時間是否顯示為秒表。 |
boolean | isTapDismissed() | 檢查當(dāng)前通知是否會在被點擊后自動關(guān)閉。 |
boolean | isUnremovable() | 檢查此通知是否不可刪除。 |
boolean | marshalling(Parcel out) | 將 NotificationRequest 對象編組到 Parcel 中。 |
NotificationRequest | setAdditionalData(IntentParams extras) | 設(shè)置存儲為通知的鍵值對的額外參數(shù)。 |
NotificationRequest | setAlertOneTime(boolean isAlertOnce) | 設(shè)置是否只有一次通知提醒。 |
NotificationRequest | setAutoDeletedTime(long time) | 設(shè)置刪除通知的時間。 |
NotificationRequest | setBadgeIconStyle(int badgeIconStyle) | 設(shè)置此通知的徽章圖標(biāo)樣式。 |
NotificationRequest | setBadgeNumber(int number) | 設(shè)置要為此通知顯示的數(shù)字。 |
NotificationRequest | setBigIcon(PixelMap bigIcon) | 設(shè)置此通知的大圖標(biāo),通常顯示在通知的右側(cè)。 |
NotificationRequest | setClassification(String classification) | 設(shè)置此通知的分類,描述此通知的用途。 |
NotificationRequest | setColor(int color) | 設(shè)置此通知的背景顏色。 |
NotificationRequest | setColorEnabled(boolean colorEnabled) | 設(shè)置是否為此通知啟用背景顏色。 |
NotificationRequest | setContent(NotificationRequest.NotificationContent content) | 將通知內(nèi)容類型設(shè)置為 NotificationRequest.NotificationNormalContent、NotificationRequest.NotificationLongTextContent 或 NotificationRequest.NotificationPictureContent。 |
NotificationRequest | setCountdownTimer(boolean isCountDown) | 設(shè)置是否將通知創(chuàng)建時間顯示為倒計時。 |
NotificationRequest | setCreateTime(long createTime) | 已棄用。 此更改從 API 版本 2 開始生效。 createTime 在初始化 NotificationRequest 時占用系統(tǒng)時間。 |
NotificationRequest | setCustomBigView(ComponentProvider view) | 設(shè)置展開此通知時要顯示的自定義視圖。 |
NotificationRequest | setCustomFloatView(ComponentProvider view) | 設(shè)置當(dāng)此通知顯示為屏幕頂部的浮動窗口時要顯示的自定義視圖。 |
NotificationRequest | setCustomView(ComponentProvider view) | 設(shè)置此通知的自定義視圖。 |
NotificationRequest | setDeliveryTime(long deliveryTime) | 設(shè)置發(fā)送通知的時間。 |
NotificationRequest | setGroupAlertType(int groupAlertType) | 設(shè)置此通知的組警報類型,這決定了組概述和組中其他通知的發(fā)布方式。 |
NotificationRequest | setGroupOverview(boolean groupOverview) | 設(shè)置是否將此通知用作其組的概述。 |
NotificationRequest | setGroupValue(String groupValue) | 設(shè)置此通知的組信息。 |
NotificationRequest | setInProgress(boolean isOngoing) | 設(shè)置此通知是否正在進行中。 |
NotificationRequest | setIntentAgent(IntentAgent agent) | 向此通知添加 IntentAgent。 |
NotificationRequest | setLittleIcon(PixelMap littleIcon) | 設(shè)置通知的小圖標(biāo)。 |
NotificationRequest | setMaxScreenIntentAgent(IntentAgent maxScreenIntentAgent) | 將 IntentAgent 設(shè)置為在設(shè)備未使用時啟動,而不是在狀態(tài)欄中顯示此通知。 |
NotificationRequest | setNotificationId(int notificationId) | 設(shè)置當(dāng)前通知 ID 以唯一標(biāo)識應(yīng)用程序中的通知。 |
NotificationRequest | setNotificationUserInputHistory(ListString text) | 設(shè)置已通過此通知發(fā)送的最新 NotificationUserInput 記錄。 |
NotificationRequest | setOnlyLocal(boolean flag) | 設(shè)置此通知是否僅與本地設(shè)備相關(guān),而不能在遠程設(shè)備上顯示。 |
NotificationRequest | setPermitSystemGeneratedContextualActionButtons(boolean permitted) | 設(shè)置是否允許平臺為此通知生成上下文 NotificationActionButton 對象。 |
NotificationRequest | setProgressBar(int progress, int progressMax, boolean indeterminate) | 設(shè)置此通知的進度條顯示方式。 |
NotificationRequest | setPublicNotification(NotificationRequest request) | 為此通知設(shè)置要在鎖定屏幕上顯示的替代通知。 |
NotificationRequest | setRemovalIntentAgent(IntentAgent removalIntentAgent) | 設(shè)置當(dāng)用戶顯式刪除此通知時觸發(fā)的 IntentAgent 對象。 |
NotificationRequest | setSettingsText(String text) | 設(shè)置將顯示為應(yīng)用程序設(shè)置鏈接的文本。 |
NotificationRequest | setShortcutId(String shortcutId) | 設(shè)置此通知的快捷方式 ID。 |
NotificationRequest | setShowCreateTime(boolean showCreateTime) | 已棄用。 此更改從 API 版本 2 開始生效。通知顯示的是交付時間,而不是創(chuàng)建時間。 請改用 setShowDeliveryTime(boolean)。 |
NotificationRequest | setShowDeliveryTime(boolean showDeliveryTime) | 設(shè)置是否顯示此通知的通知傳遞時間。 |
NotificationRequest | setShowStopwatch(boolean isStopwatch) | 設(shè)置是否將通知創(chuàng)建時間顯示為秒表。 |
NotificationRequest | setSlotId(String slotId) | 設(shè)置通知的槽 ID 以綁定創(chuàng)建的 NotificationSlot 對象。 |
NotificationRequest | setSortingKey(String key) | 設(shè)置用于對來自同一應(yīng)用程序包的通知進行排序的鍵。 |
NotificationRequest | setStatusBarText(String statusBarText) | 設(shè)置收到此通知時在狀態(tài)欄中顯示的滾動文本。 |
NotificationRequest | setTapDismissed(boolean tapDismissed) | 設(shè)置是否在被點擊后自動關(guān)閉通知。 |
NotificationRequest | setUnremovable(boolean isUnremovable) | 設(shè)置此通知是否不可刪除。 |
NotificationRequest | setVisibleness(int visibleness) | 設(shè)置通知顯示效果,包括是否在鎖屏上顯示該通知,以及顯示后如何呈現(xiàn)。 |
String | toString() | 返回對象的字符串表示形式。 |
boolean | unmarshalling(Parcel in) | 從 Parcel 中解組 NotificationRequest 對象。 |
從類 java.lang.Object 繼承的方法 |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
從接口 ohos.utils.Sequenceable 繼承的方法 |
---|
hasFileDescriptor |
public static final int BADGE_STYLE_BIG
表示此通知的標(biāo)記顯示為大圖標(biāo)。
Since:
4
public static final int BADGE_STYLE_LITTLE
表示此通知的標(biāo)記顯示為一個小圖標(biāo)。
Since:
4
public static final int BADGE_STYLE_NONE
表示此通知的標(biāo)記僅顯示數(shù)字。
Since:
4
public static final String CLASSIFICATION_ALARM
指示警報或定時器的通知分類。
Since:
3
public static final String CLASSIFICATION_CALL
指示傳入呼叫或類似同步通信請求的通知分類。
Since:
3
public static final String CLASSIFICATION_EMAIL
指示電子郵件通知的分類。
Since:
3
public static final String CLASSIFICATION_ERROR
指示在后臺操作或身份驗證過程中發(fā)生的錯誤通知的分類。
Since:
3
public static final String CLASSIFICATION_EVENT
表示日歷事件通知的分類。表示日歷事件的通知分類。
Since:
3
public static final String CLASSIFICATION_MESSAGE
指示短消息或即時消息的通知分類。
Since:
3
public static final String CLASSIFICATION_NAVIGATION
表示地圖導(dǎo)航通知的分類。
Since:
3
public static final String CLASSIFICATION_PROGRESS
表示長時間在后臺運行的進程的通知分類。
Since:
3
public static final String CLASSIFICATION_PROMO
表示廣告或促銷信息通知的分類。
Since:
3
public static final String CLASSIFICATION_RECOMMENDATION
指示特定交易的具體及時建議的通知分類。
Since:
3
public static final String CLASSIFICATION_REMINDER
指示用戶先前設(shè)置的提醒的通知分類。
Since:
3
public static final String CLASSIFICATION_SERVICE
指示正在進行的后臺服務(wù)的通知分類。
Since:
3
public static final String CLASSIFICATION_SOCIAL
指示社交網(wǎng)絡(luò)或共享更新通知的分類。
Since:
3
public static final String CLASSIFICATION_STATUS
指示有關(guān)設(shè)備和上下文狀態(tài)的持續(xù)信息的通知分類。
Since:
3
public static final String CLASSIFICATION_SYSTEM
指示系統(tǒng)或設(shè)備狀態(tài)更新通知的分類。
Since:
3
public static final String CLASSIFICATION_TRANSPORT
表示播放過程中媒體傳輸控制的通知分類。
Since:
3
public static final int COLOR_DEFAULT
表示默認(rèn)通知背景顏色,即不顯示顏色。
Since:
3
public static final String EXTRA_USER_INPUT_HISTORY
getAdditionalData() 鍵:這是用戶輸入歷史記錄,提供給 setNotificationUserInputHistory(java.util.List)。
Since:
3
public static final int GROUP_ALERT_TYPE_ALL
通知組警報類型,如果為關(guān)聯(lián)的 NotificationSlot 對象啟用聲音或振動,則指示組中的所有通知都有聲音或振動。
Since:
3
public static final int GROUP_ALERT_TYPE_CHILD
通知組警報類型,指示子通知有聲音或振動,但如果為關(guān)聯(lián)的 NotificationSlot 對象啟用聲音或振動,則組中的概覽通知會靜音(無聲音或振動)。
Since:
3
public static final int GROUP_ALERT_TYPE_OVERVIEW
通知組警報類型,指示概覽通知有聲音或振動,但如果為關(guān)聯(lián)的 NotificationSlot 對象啟用聲音或振動,則組中的子通知將靜音(無聲音或振動)。
Since:
3
public static final Sequenceable.ProducerNotificationRequest PRODUCER
從 Parcel 創(chuàng)建 NotificationRequest 實例。
Since:
4
public static final int VISIBLENESS_TYPE_NO_OVERRIDE
表示未通過setVisibleness(int)設(shè)置通知顯示效果。 這種方法通常不使用。
Since:
3
public static final int VISIBLENESS_TYPE_PRIVATE
表示鎖屏上只顯示應(yīng)用程序圖標(biāo)、應(yīng)用程序名稱等基本信息。
Since:
3
public static final int VISIBLENESS_TYPE_PUBLIC
表示通知的內(nèi)容顯示在鎖定屏幕上。
Since:
3
public static final int VISIBLENESS_TYPE_SECRET
表示通知不顯示在鎖定屏幕上。
Since:
3
public NotificationRequest(NotificationRequest request)
用于通過從現(xiàn)有參數(shù)復(fù)制參數(shù)來創(chuàng)建 NotificationRequest 實例的構(gòu)造函數(shù)。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
request | 指示現(xiàn)有的 NotificationRequest 對象。 |
Since:
1
public NotificationRequest()
用于創(chuàng)建 NotificationRequest 實例的默認(rèn)構(gòu)造函數(shù)。
Since:
1
public NotificationRequest(int notificationId)
一個構(gòu)造函數(shù),用于創(chuàng)建一個 NotificationRequest 實例,并傳遞了輸入?yún)?shù) notificationId。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
notificationId | 通知ID,必須唯一。 您可以將其設(shè)置為任何 int 值。 |
Since:
1
public NotificationRequest(Context context, int notificationId)
用于根據(jù)指定的上下文和通知 ID 創(chuàng)建 NotificationRequest 實例的構(gòu)造函數(shù)。 要使用自定義視圖發(fā)布通知,您必須使用指定的 Context 調(diào)用此類構(gòu)造函數(shù)。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
context | 指示當(dāng)前應(yīng)用程序或能力的上下文。 如果要發(fā)布帶有自定義視圖的通知,此參數(shù)不能為空。 |
notificationId | 通知ID,必須唯一。 您可以將其設(shè)置為任何 int 值。 |
Since:
3
public NotificationRequest setCustomView(ComponentProvider view)
設(shè)置此通知的自定義視圖。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
view | 表示定義自定義視圖的 ComponentProvider 對象。 |
返回:
返回具有自定義視圖的 NotificationRequest 對象。
Since:
3
public ComponentProvider getCustomView()
獲取定義此通知中設(shè)置的自定義視圖的 ComponentProvider 對象。 ComponentProvider 對象在 setCustomView(ohos.agp.components.ComponentProvider) 中設(shè)置。
返回:
返回定義自定義視圖的 ComponentProvider 對象。
Since:
3
public NotificationRequest setCustomBigView(ComponentProvider view)
設(shè)置展開此通知時要顯示的自定義視圖。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
view | 表示定義自定義視圖的 ComponentProvider 對象。 |
返回:
返回具有自定義視圖的 NotificationRequest 對象。
Since:
3
public ComponentProvider getCustomBigView()
獲取定義此通知展開時要顯示的自定義視圖的 ComponentProvider 對象。 ComponentProvider 對象在 setCustomBigView(ohos.agp.components.ComponentProvider) 中設(shè)置。
返回:
返回定義自定義視圖的 ComponentProvider 對象。
Since:
3
public NotificationRequest setCustomFloatView(ComponentProvider view)
設(shè)置當(dāng)此通知顯示為屏幕頂部的浮動窗口時要顯示的自定義視圖。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
view | 表示定義自定義視圖的 ComponentProvider 對象。 |
返回:
返回具有自定義視圖的 NotificationRequest 對象。
Since:
3
public ComponentProvider getCustomFloatView()
獲取定義當(dāng)此通知顯示為屏幕頂部的浮動窗口時要顯示的自定義視圖的 ComponentProvider 對象。 ComponentProvider 對象在 setCustomFloatView(ohos.agp.components.ComponentProvider) 中設(shè)置。
返回:
返回定義自定義視圖的 ComponentProvider 對象。
Since:
3
public NotificationRequest setOnlyLocal(boolean flag)
設(shè)置此通知是否僅與本地設(shè)備相關(guān),而不能在遠程設(shè)備上顯示。 該方法僅對調(diào)用 NotificationHelper#publishNotification(NotificationRequest) 或 NotificationHelper#publishNotification(String, NotificationRequest) 發(fā)布的通知生效。 在分布式系統(tǒng)中使用 NotificationHelper#publishNotification(NotificationRequest, String) 發(fā)布的通知不會受到影響。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
flag | 指定此通知是否只能在本地設(shè)備上顯示。 true 表示只能在本地設(shè)備上顯示,false 表示也可以在遠程設(shè)備上顯示。 |
返回:
返回具有指定標(biāo)志的 NotificationRequest 對象。
Since:
3
public boolean isOnlyLocal()
檢查此通知是否僅與本地設(shè)備相關(guān),不能在遠程設(shè)備上顯示。
返回:
如果此通知僅與本地設(shè)備相關(guān),則返回 true; 否則返回 false。
Since:
3
public NotificationRequest setSortingKey(String key)
設(shè)置用于對來自同一應(yīng)用程序包的通知進行排序的鍵。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
key | 表示要設(shè)置的鍵。 |
返回:
返回具有指定鍵的 NotificationRequest 對象。
Since:
3
public String getSortingKey()
獲取用于對來自同一應(yīng)用程序包的通知進行排序的密鑰。
返回:
返回排序通知的鍵。
Since:
3
public long getAutoDeletedTime()
獲取通知被刪除的時間。
返回:
返回以毫秒為單位的周期。
Since:
1
public String getNotificationHashCode()
獲取當(dāng)前應(yīng)用中通知的唯一哈希碼。
要獲取有效的哈希碼,您必須已訂閱并收到通知。 有效的通知哈希碼是由多個屬性組成的字符串,由下劃線 (_) 分隔,包括通知 ID、創(chuàng)建者捆綁包名稱、創(chuàng)建者 UID 和所有者捆綁包名稱。
返回:
返回通知的哈希碼。
Since:
1
public NotificationRequest setLittleIcon(PixelMap littleIcon)
設(shè)置通知的小圖標(biāo)。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
littleIcon | 表示通知的圖標(biāo)。 |
返回:
返回具有指定圖標(biāo)的 NotificationRequest 對象。
Since:
1
public PixelMap getLittleIcon()
獲取通知的圖標(biāo)。
返回:
返回通知圖標(biāo)。
Since:
1
public NotificationRequest setBigIcon(PixelMap bigIcon)
設(shè)置此通知的大圖標(biāo),通常顯示在通知的右側(cè)。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
bigIcon | 表示要設(shè)置的大圖標(biāo)。 它必須是一個 PixelMap 對象。 |
返回:
返回具有指定 bigIcon 設(shè)置的 NotificationRequest 對象。
Since:
3
public PixelMap getBigIcon()
獲取該通知的大圖標(biāo)。
返回:
返回此通知的大圖標(biāo)。
Since:
3
public NotificationRequest setAutoDeletedTime(long time)
設(shè)置刪除通知的時間。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
time | 以毫秒為單位表示時間。 默認(rèn)值為0,表示不會自動刪除通知。 要使通知自動刪除,請將此參數(shù)設(shè)置為大于0的整數(shù)。 |
返回:
返回指定時間的 NotificationRequest 對象。
Since:
1
public boolean isTapDismissed()
檢查當(dāng)前通知是否會在被點擊后自動關(guān)閉。
返回:
如果通知將被自動關(guān)閉,則返回 true; 否則返回 false。
Since:
1
public NotificationRequest setTapDismissed(boolean tapDismissed)
設(shè)置是否在被點擊后自動關(guān)閉通知。
如果將 tapDismissed 設(shè)置為 true,則必須調(diào)用 setIntentAgent(ohos.event.intentagent.IntentAgent) 方法才能使設(shè)置生效。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
tapDismissed | 指定是否在點擊后自動關(guān)閉通知。 true 表示已關(guān)閉,false 表示未關(guān)閉。 |
返回:
返回具有指定的 tapDismissed 設(shè)置的 NotificationRequest 對象。
Since:
1
@Deprecated public long getCreateTime()
已棄用。 此更改從 API 版本 2 開始生效。初始化 NotificationRequest 的時間對公眾是不可訪問的。 要獲取發(fā)送通知的時間,請調(diào)用 getDeliveryTime() 方法。
獲取創(chuàng)建通知的時間。
返回:
返回以毫秒為單位的時間。
Since:
1
@Deprecated public NotificationRequest setCreateTime(long createTime)
已棄用。 此更改從 API 版本 2 開始生效。 createTime 在初始化 NotificationRequest 時占用系統(tǒng)時間。
設(shè)置創(chuàng)建通知的時間。初始化的 NotificationRequest 中的默認(rèn)時間是初始化的時間。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
createTime | 以毫秒為單位表示時間。 |
返回:
返回具有指定 createTime 的 NotificationRequest 對象。
Since:
1
@Deprecated public boolean isShowCreateTime()
已棄用。 此更改從 API 版本 2 開始生效。請改用 isShowDeliveryTime()。 通知顯示它的發(fā)送時間,而不是它的創(chuàng)建時間。
檢查是否顯示此通知的通知創(chuàng)建時間。
返回:
如果顯示時間,則返回 true; 否則返回 false。
Since:
1
@Deprecated public NotificationRequest setShowCreateTime(boolean showCreateTime)
已棄用。 此更改從 API 版本 2 開始生效。通知顯示的是交付時間,而不是創(chuàng)建時間。 請改用 setShowDeliveryTime(boolean)。
設(shè)置是否顯示此通知的通知創(chuàng)建時間。 此方法僅在通過調(diào)用 setCreateTime(long) 設(shè)置通知創(chuàng)建時間時有效。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
showCreateTime | 指定是否顯示通知創(chuàng)建時間。 true 表示顯示,false 表示不顯示。 |
返回:
返回具有指定 showCreateTime 設(shè)置的 NotificationRequest 對象。
Since:
1
public boolean isShowDeliveryTime()
檢查是否顯示此通知的通知傳遞時間。
返回:
如果顯示時間,則返回 true; 否則返回 false。
Since:
4
public NotificationRequest setShowDeliveryTime(boolean showDeliveryTime)
設(shè)置是否顯示此通知的通知傳遞時間。 該方法僅在調(diào)用 setDeliveryTime(long) 設(shè)置了通知發(fā)送時間時有效。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
showDeliveryTime | 指定是否顯示通知傳遞時間。 true 表示顯示,false 表示不顯示。 |
返回:
返回具有指定 showDeliveryTime 設(shè)置的 NotificationRequest 對象。
Since:
4
public long getDeliveryTime()
獲取通知下發(fā)的時間。
返回:
返回以毫秒為單位的時間。
Since:
1
public NotificationRequest setDeliveryTime(long deliveryTime)
設(shè)置發(fā)送通知的時間。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
deliveryTime | 以毫秒為單位表示時間。 |
返回:
返回具有指定交付時間的 NotificationRequest 對象。
Since:
1
public IntentAgent getIntentAgent()
獲取此通知中包含的 IntentAgent。
返回:
返回此通知中包含的 IntentAgent。
Since:
3
public NotificationRequest setIntentAgent(IntentAgent agent)
向此通知添加 IntentAgent。
一個通知被點擊后,后續(xù)的操作,如能力和普通事件,將按照 IntentAgent 的設(shè)置觸發(fā)。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
agent | 表示點擊通知觸發(fā)的操作,可以通過IntentAgent設(shè)置。 |
返回:
返回具有指定代理的 NotificationRequest 對象。
Since:
3
public int getNotificationId()
獲取通知ID,在當(dāng)前應(yīng)用中是唯一的。
返回:
返回通知 ID。
Since:
1
public String getSlotId()
通過調(diào)用setSlotId(java.lang.String)方法獲取通知集的槽位ID。
返回:
返回通知槽 ID。
Since:
1
public NotificationRequest setNotificationId(int notificationId)
設(shè)置當(dāng)前通知 ID 以唯一標(biāo)識應(yīng)用程序中的通知。
收到通知后,通過 getNotificationId() 方法獲取其 ID。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
notificationId | 表示要設(shè)置的通知的ID。 您可以將其設(shè)置為任何 int 值。 |
返回:
返回具有指定 notificationId 的 NotificationRequest 對象。
Since:
1
public NotificationRequest setSlotId(String slotId)
設(shè)置通知的槽 ID 以綁定創(chuàng)建的 NotificationSlot 對象。
您可以使用 NotificationSlot 創(chuàng)建一個 slot 對象,然后設(shè)置通知振動和鎖屏顯示,并使用 current 方法綁定 slot。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
slotId | NotificationSlot 對象的唯一標(biāo)識。 該值必須是現(xiàn)有 NotificationSlot 對象的 ID。 否則,此方法不生效。 |
返回:
返回具有指定 slotId 的 NotificationRequest 對象。
Since:
1
public NotificationRequest.NotificationContent getContent()
調(diào)用setContent(ohos.event.notification.NotificationRequest.NotificationContent)方法獲取通知內(nèi)容集。
返回:
返回通知內(nèi)容。
Since:
1
public NotificationRequest setContent(NotificationRequest.NotificationContent content)
將通知內(nèi)容類型設(shè)置為 NotificationRequest.NotificationNormalContent、NotificationRequest.NotificationLongTextContent 或 NotificationRequest.NotificationPictureContent。
每個內(nèi)容類型表示一個特定的通知內(nèi)容。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
content | 指示通知內(nèi)容類型。 |
返回:
返回具有指定內(nèi)容的 NotificationRequest 對象。
Since:
1
public NotificationRequest setAdditionalData(IntentParams extras)
設(shè)置存儲為通知的鍵值對的額外參數(shù)。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
extras | 表示包含鍵值對格式的額外參數(shù)的 IntentParams 對象。 |
返回:
返回包含由 extras 指定的額外參數(shù)的 NotificationRequest 對象。
Since:
2
public IntentParams getAdditionalData()
獲取通知中設(shè)置的 IntentParams 對象。
返回:
返回 IntentParams 對象。
Since:
2
public NotificationRequest setSettingsText(String text)
設(shè)置將顯示為應(yīng)用程序設(shè)置鏈接的文本。
如果通過 setContent(ohos.event.notification.NotificationRequest.NotificationContent) 在 NotificationRequest 對象中將通知內(nèi)容類型設(shè)置為 NotificationRequest.NotificationLongTextContent 或 NotificationRequest.NotificationPictureContent,則調(diào)用該方法無效。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
text | 指示要包含的文本。 您可以將其設(shè)置為任何有效的鏈接。 |
返回:
返回具有指定文本的 NotificationRequest 對象。
Since:
2
public String getSettingsText()
獲取將顯示為應(yīng)用程序設(shè)置鏈接的文本。
返回:
返回顯示為應(yīng)用程序設(shè)置鏈接的文本。
Since:
2
public int getNotificationType()
獲取通知類型。
返回:
返回當(dāng)前通知的類型,可以是 NotificationContent#NOTIFICATION_CONTENT_BASIC_TEXT、NotificationContent#NOTIFICATION_CONTENT_LONG_TEXT、NotificationContent#NOTIFICATION_CONTENT_PICTURE、NotificationContent#NOTIFICATION_CONTENT_CONVERSATION、NotificationContent#NOTIFICATION_CONTENT_MULTILINE 或 NotificationContent#NOTIFICATION_CONTENT_MEDIA。
Since:
2
public String getCreatorBundleName()
獲取通知創(chuàng)建者的包名。
通知創(chuàng)建者是指發(fā)布通知的應(yīng)用程序。
返回:
返回通知創(chuàng)建者的包名稱。
Since:
2
public String getOwnerBundleName()
獲取通知所有者的捆綁包名稱。
通知所有者是指訂閱通知的應(yīng)用程序。
返回:
返回通知所有者的包名稱。
Since:
2
public int getCreatorPid()
獲取通知創(chuàng)建者的PID。
通知創(chuàng)建者是指發(fā)布通知的應(yīng)用程序。
返回:
返回通知創(chuàng)建者的 PID。
Since:
2
public int getCreatorUid()
獲取通知創(chuàng)建者的 UID。
通知創(chuàng)建者是指發(fā)布通知的應(yīng)用程序。
返回:
返回通知創(chuàng)建者的 UID。
Since:
2
public String getGroupValue()
獲取本次通知的組信息。
返回:
返回有關(guān)此通知的組信息。
Since:
3
public NotificationRequest setGroupValue(String groupValue)
設(shè)置此通知的組信息。
如果沒有為通知設(shè)置組,來自同一應(yīng)用程序的所有通知將在通知欄中顯示為一個堆棧,并顯示堆棧的通知數(shù)量。 如果通知被分組并且有多個由不同 groupValue 標(biāo)識的組,則具有不同 groupValue 的通知將出現(xiàn)在不同的堆棧中。
請注意,必須通過調(diào)用 setGroupOverview(boolean) 將組中的一個通知設(shè)置為其組的概覽,其他通知視為子通知。 否則,即使通過調(diào)用 setGroupValue(java.lang.String) 為它們分配了相同的 groupValue,通知也不會顯示為一組。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
groupValue | 指示要為此通知設(shè)置的組值。 |
返回:
返回具有指定 groupValue 的 NotificationRequest 對象。
Since:
3
public int getGroupAlertType()
獲取該通知的群組告警類型。
返回:
返回此通知的組警報類型。
Since:
3
public NotificationRequest setGroupAlertType(int groupAlertType)
設(shè)置此通知的組警報類型,這決定了組概述和組中其他通知的發(fā)布方式。
必須通過調(diào)用 setGroupValue(java.lang.String) 設(shè)置組信息。 否則,此方法不生效。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
groupAlertType | 指示要設(shè)置的組警報類型,可以是 GROUP_ALERT_TYPE_ALL(默認(rèn)值)、GROUP_ALERT_TYPE_OVERVIEW 或 GROUP_ALERT_TYPE_CHILD。 |
返回:
返回具有指定 groupAlertType 的 NotificationRequest 對象。
Since:
3
public boolean isGroupOverview()
檢查此通知是否為組概覽。
返回:
如果此通知是組概述,則返回 true; 否則返回 false。
Since:
3
public NotificationRequest setGroupOverview(boolean groupOverview)
設(shè)置是否將此通知用作其組的概述。 此方法通過調(diào)用 setGroupValue(java.lang.String) 作為通知欄中的一個堆棧來幫助顯示分配了相同組值的通知。
每個組只需要一個組概覽。 將通知設(shè)置為組概覽后,如果同一組中的另一個通知發(fā)布,則該通知將變?yōu)椴豢梢姟?/p>
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
groupOverview | 指定是否將此通知設(shè)置為組概覽。 值 true 表示它是組概覽,值 false 表示不是。 |
返回:
返回具有指定 groupOverview 設(shè)置的 NotificationRequest 對象。
Since:
3
public IntentAgent getRemovalIntentAgent()
獲取用戶顯式移除此通知時觸發(fā)的 IntentAgent 對象。
返回:
返回要觸發(fā)的 IntentAgent 對象。
Since:
3
public NotificationRequest setRemovalIntentAgent(IntentAgent removalIntentAgent)
設(shè)置當(dāng)用戶顯式刪除此通知時觸發(fā)的 IntentAgent 對象。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
removalIntentAgent | 指示要觸發(fā)的 IntentAgent 對象。 |
返回:
返回具有指定removingIntentAgent 的NotificationRequest 對象。
Since:
3
public String getClassification()
獲取此通知的分類。
返回:
返回此通知的分類。
Since:
3
public NotificationRequest setClassification(String classification)
設(shè)置此通知的分類,描述此通知的用途。 通知分類用于過濾和排序通知。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
classification | 表示系統(tǒng)預(yù)定義的通知分類,如CLASSIFICATION_CALL或CLASSIFICATION_NAVIGATION。 |
返回:
返回具有指定分類的 NotificationRequest 對象。
Since:
3
public IntentAgent getMaxScreenIntentAgent()
調(diào)用setMaxScreenIntentAgent(ohos.event.intentagent.IntentAgent)獲取全屏IntentAgent集合。
返回:
返回全屏 IntentAgent。
Since:
3
public NotificationRequest setMaxScreenIntentAgent(IntentAgent maxScreenIntentAgent)
將 IntentAgent 設(shè)置為在設(shè)備未使用時啟動,而不是在狀態(tài)欄中顯示此通知。
設(shè)備在使用時,系統(tǒng)UI會彈出通知,而不是啟動maxScreenIntentAgent指定的IntentAgent。
您的應(yīng)用程序必須具有 ohos.permission.USE_WHOLE_SCREEN 權(quán)限才能使用此方法。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
maxScreenIntentAgent | 指示 IntentAgent 對象,其中包含有關(guān)使用 Page 模板的待啟動能力的信息。 |
返回:
返回具有指定 maxScreenIntentAgent 的 NotificationRequest 對象。
Since:
3
public int getColor()
獲取此通知的背景顏色。
返回值除默認(rèn)顏色COLOR_DEFAULT外,為0xFF000000與setColor(int)設(shè)置的ARGB值的按位或運算結(jié)果。
返回:
返回此通知的背景顏色。
Since:
3
public NotificationRequest setColor(int color)
設(shè)置此通知的背景顏色。 此方法僅在通過調(diào)用 setColorEnabled(boolean) 啟用背景顏色時有效。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
color | 指示要設(shè)置的背景顏色。 |
返回:
返回具有指定顏色的 NotificationRequest 對象。
Since:
3
public boolean isColorEnabled()
檢查是否為此通知啟用了背景顏色。
返回:
如果啟用背景顏色,則返回 true; 否則返回 false。
Since:
3
public NotificationRequest setColorEnabled(boolean colorEnabled)
設(shè)置是否為此通知啟用背景顏色。
如果 colorEnabled 設(shè)置為 true,則此方法僅在通過 NotificationRequest#setContent(NotificationContent) 將 NotificationRequest 對象中的通知內(nèi)容類型設(shè)置為 NotificationRequest.NotificationMediaContent 并且已通過 NotificationMediaContent#setAVToken( AVToken)。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
colorEnabled | 指定是否啟用背景顏色。 值 true 表示將啟用背景顏色,值 false 表示不啟用。 |
返回:
返回具有指定 colorEnabled 設(shè)置的 NotificationRequest 對象。
Since:
3
public int getBadgeNumber()
獲取要為此通知顯示的編號。
返回:
返回要為此通知顯示的數(shù)字。
Since:
3
public NotificationRequest setBadgeNumber(int number)
設(shè)置要為此通知顯示的數(shù)字。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
number | 表示要設(shè)置的數(shù)字。 |
返回:
返回具有指定編號的 NotificationRequest 對象。
Since:
3
public boolean isAlertOneTime()
檢查此通知是否設(shè)置為僅提醒一次,這意味著在更新具有相同 ID 的通知時將不再播放聲音或振動。
返回:
如果此通知設(shè)置為僅提醒一次,則返回 true; 否則返回 false。
Since:
3
public NotificationRequest setAlertOneTime(boolean isAlertOnce)
設(shè)置是否只有一次通知提醒。 如果一個通知只提醒一次,同一個 ID 的通知在發(fā)布后更新時將不再播放聲音或振動。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
isAlertOnce | 指定是否只有一次通知警報。 值 true 表示該通知將只提示一次,值 false 表示不會。 |
返回:
返回具有指定 isAlertOnce 設(shè)置的 NotificationRequest 對象。
Since:
3
public boolean isShowStopwatch()
檢查通知創(chuàng)建時間是否顯示為秒表。
返回:
如果時間顯示為秒表,則返回 true; 否則返回 false。
Since:
3
public NotificationRequest setShowStopwatch(boolean isStopwatch)
設(shè)置是否將通知創(chuàng)建時間顯示為秒表。 此方法僅在通過調(diào)用 setDeliveryTime(long) 設(shè)置通知創(chuàng)建時間時有效。
當(dāng)通知創(chuàng)建時間設(shè)置為顯示為秒表時,當(dāng)前時間與 setDeliveryTime(long) 設(shè)置的創(chuàng)建時間之間的時間間隔以分鐘:秒格式動態(tài)顯示此通知。 如果間隔時間超過 60 分鐘,將以小時:分鐘:秒格式顯示。 如果該方法和setShowDeliveryTime(boolean)都設(shè)置為true,則只有該方法生效,即通知創(chuàng)建時間會顯示為秒表。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
isStopwatch | 指定是否將通知創(chuàng)建時間顯示為秒表。 值 true 表示它顯示為秒表,值 false 表示不顯示。 |
返回:
返回具有指定 isStopwatch 設(shè)置的 NotificationRequest 對象。
Since:
3
public boolean isCountdownTimer()
檢查通知創(chuàng)建時間是否顯示為倒計時。
返回:
如果時間顯示為倒數(shù)計時器,則返回 true; 否則返回 false。
Since:
3
public NotificationRequest setCountdownTimer(boolean isCountDown)
設(shè)置是否將通知創(chuàng)建時間顯示為倒計時。 此方法僅在 setShowStopwatch(boolean) 設(shè)置為 true 時有效。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
isCountDown | 指定是否將通知創(chuàng)建時間顯示為倒計時。 值 true 表示它顯示為倒數(shù)計時器,值 false 表示不顯示。 |
返回:
返回具有指定 isCountDown 設(shè)置的 NotificationRequest 對象。
Since:
3
public boolean isInProgress()
檢查此通知是否正在進行中。
返回:
如果此通知正在進行,則返回 true; 否則返回 false。
Since:
3
public NotificationRequest setInProgress(boolean isOngoing)
設(shè)置此通知是否正在進行中。
用戶不能直接關(guān)閉正在進行的通知,因為它們通常包含一些正在進行的后臺服務(wù),例如音樂播放。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
isOngoing | 指定此通知是否正在進行中。 值 true 表示通知正在進行中,值 false 表示沒有。 |
返回:
返回具有指定 isOngoing 設(shè)置的 NotificationRequest 對象。
Since:
3
public int getVisibleness()
獲取該通知在鎖屏?xí)r的顯示效果。
返回:
返回此通知在鎖屏?xí)r的顯示效果。
Since:
3
public NotificationRequest setVisibleness(int visibleness)
設(shè)置通知顯示效果,包括是否在鎖屏上顯示該通知,以及顯示后如何呈現(xiàn)。
如果為NotificationRequest對象及其關(guān)聯(lián)的NotificationSlot對象設(shè)置了鎖屏顯示效果,則以NotificationRequest對象中設(shè)置的顯示效果為準(zhǔn)。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
visibleness | 表示鎖屏上的通知顯示效果,可設(shè)置為VISIBLENESS_TYPE_PUBLIC、VISIBLENESS_TYPE_PRIVATE、VISIBLENESS_TYPE_SECRET或VISIBLENESS_TYPE_NO_OVERRIDE。 |
返回:
返回具有指定可見性的 NotificationRequest 對象。
Since:
3
public int getProgressValue()
獲取此通知的進度條顯示的當(dāng)前值。
返回:
返回通知進度條的當(dāng)前值。
Since:
3
public int getProgressMax()
獲取此通知的進度條顯示的最大值。
返回:
返回通知進度條的最大值。
Since:
3
public boolean isProgressIndeterminate()
檢查此通知的進度條是否不確定。
返回:
如果通知進度條不確定,則返回 true; 否則返回 false。
Since:
3
public NotificationRequest setProgressBar(int progress, int progressMax, boolean indeterminate)
設(shè)置此通知的進度條顯示方式。
進度條通常用于下載等通知場景。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
progress | 指示通知進度條顯示的當(dāng)前值。 |
progressMax | 表示通知進度條顯示的最大值。 |
indeterminate | 指定進度條是否不確定。 值 true 表示進度條是不確定的,用戶看不到它的當(dāng)前值和最大值。 |
返回:
返回具有指定進度、progressMax 和不確定設(shè)置的 NotificationRequest 對象。
Since:
3
public String getStatusBarText()
獲取收到此通知時將在狀態(tài)欄中顯示的滾動文本。
返回:
返回滾動通知文本。
Since:
3
public NotificationRequest setStatusBarText(String statusBarText)
設(shè)置收到此通知時在狀態(tài)欄中顯示的滾動文本。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
statusBarText | 指示要顯示的滾動文本。 |
返回:
返回具有指定 statusBarText 的 NotificationRequest 對象。
Since:
3
public boolean isUnremovable()
檢查此通知是否不可刪除。
返回:
如果此通知不可移除,則返回 true; 否則返回 false。
Since:
3
public NotificationRequest setUnremovable(boolean isUnremovable)
設(shè)置此通知是否不可刪除。
如果設(shè)置為不可移除,則用戶無法移除。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
isUnremovable | 指定此通知是否不可刪除。 true 表示不可移除,false 表示可移除。 |
返回:
返回具有指定 isUnremovable 設(shè)置的 NotificationRequest 對象。
Since:
3
public boolean isFloatingIcon()
檢查此通知是否顯示為屏幕頂部的浮動圖標(biāo)。
返回:
如果此通知顯示為浮動圖標(biāo),則返回 true; 否則返回 false。
Since:
3
public NotificationRequest addActionButton(NotificationActionButton actionButton)
向此通知添加 NotificationActionButton。 系統(tǒng)通常會在通知內(nèi)容旁邊放置操作按鈕。
每個操作按鈕必須包含一個圖標(biāo)、一個標(biāo)題和一個 IntentAgent。 展開通知時,最多可以按添加順序從左到右顯示三個操作按鈕。 折疊通知時,不會顯示任何操作按鈕。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
actionButton | 指示要添加的 NotificationActionButton 對象。 |
返回:
返回具有指定 actionButton 的 NotificationRequest 對象。
Since:
3
public ListNotificationActionButton getActionButtons()
獲取包含在此通知中的所有 NotificationActionButton 對象的列表。
返回:
返回 NotificationActionButton 對象的列表。
Since:
3
public NotificationRequest setPublicNotification(NotificationRequest request)
為此通知設(shè)置要在鎖定屏幕上顯示的替代通知。 顯示效果(是否以及如何顯示此替代通知)取決于 NotificationSlot#setLockscreenVisibleness(int) 中的配置。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
request | 指示要在鎖定屏幕上顯示的替代通知。 |
返回:
返回具有指定請求的 NotificationRequest 對象。
Since:
3
public NotificationRequest setPermitSystemGeneratedContextualActionButtons(boolean permitted)
設(shè)置是否允許平臺為此通知生成上下文 NotificationActionButton 對象。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
permitted | 指定是否允許平臺生成上下文 NotificationActionButton 對象。 默認(rèn)值 true 表示允許平臺生成上下文操作按鈕,值 false 表示不允許。 |
返回:
返回具有指定允許設(shè)置的 NotificationRequest 對象。
Since:
3
public boolean isPermitSystemGeneratedContextualActionButtons()
檢查是否允許平臺為此通知生成上下文 NotificationActionButton 對象。
返回:
如果允許平臺生成上下文 NotificationActionButton 對象,則返回 true; 否則返回 false。
Since:
3
public NotificationRequest setNotificationUserInputHistory(ListString text)
設(shè)置已通過此通知發(fā)送的最新 NotificationUserInput 記錄。
最近的輸入必須存儲在索引 0 中,第二最近的輸入必須存儲在索引 1 中,依此類推。 系統(tǒng)最多顯示五個輸入。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
text | 指示要設(shè)置的輸入列表。 |
返回:
返回具有指定文本的 NotificationRequest 對象。
Since:
3
public ListMessageUser getMessageUsers()
獲取與此通知關(guān)聯(lián)的所有 MessageUser 對象。
返回:
返回與此通知關(guān)聯(lián)的 MessageUser 對象列表。
Since:
3
public NotificationRequest addMessageUser(MessageUser messageUser)
添加一個 MessageUser 對象并將其與此通知相關(guān)聯(lián)。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
messageUser | 指示要添加的 MessageUser 對象。 |
返回:
返回具有指定 messageUser 的 NotificationRequest 對象。
Since:
3
public String getLabel()
獲取此通知的標(biāo)簽。
標(biāo)簽是通過 NotificationHelper#publishNotification(String, NotificationRequest) 設(shè)置的。 如果沒有為此通知設(shè)置特定標(biāo)簽,則此方法返回 null。
返回:
返回此通知的標(biāo)簽。
Since:
4
public NotificationRequest setBadgeIconStyle(int badgeIconStyle)
設(shè)置此通知的徽章圖標(biāo)樣式。
如果主屏幕不支持徽章圖標(biāo),此方法無效。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
badgeIconStyle | 指示要為此通知顯示的徽章圖標(biāo)的類型。 該值必須是 BADGE_STYLE_NONE、BADGE_STYLE_LITTLE 或 BADGE_STYLE_BIG。 |
返回:
返回具有指定 badgeIconStyle 的 NotificationRequest 對象。
Since:
4
public int getBadgeIconStyle()
獲取該通知的徽章圖標(biāo)樣式。
返回:
返回此通知的徽章圖標(biāo)樣式。
Since:
4
public NotificationRequest setShortcutId(String shortcutId)
設(shè)置此通知的快捷方式 ID。
為通知設(shè)置快捷ID后,該通知將與相應(yīng)的主屏幕快捷方式關(guān)聯(lián),當(dāng)Home應(yīng)用顯示通知的徽章或內(nèi)容時,該快捷方式將被隱藏。
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
shortcutId | 表示要設(shè)置的快捷方式ID。 |
返回:
返回具有指定快捷方式Id 的 NotificationRequest 對象。
Since:
4
public String getShortcutId()
獲取與此通知關(guān)聯(lián)的快捷方式 ID。
返回:
返回此通知的快捷方式 ID。
Since:
4
public boolean marshalling(Parcel out)
將 NotificationRequest 對象編組到 Parcel 中。
進程可以調(diào)用 unmarshalling(ohos.utils.Parcel) 方法從 Parcel 中解組 NotificationRequest 對象,以實現(xiàn)進程間通信 (IPC)。
指定者:
接口 Sequenceable 中的編組
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
out | 指示用于編組的 MessageParcel 對象。 MessageParcel 是 Parcel 的子類。 |
返回:
如果編組成功,則返回 true; 否則返回 false。
Since:
1
public boolean unmarshalling(Parcel in)
從 Parcel 中解組 NotificationRequest 對象。
指定者:
在接口 Sequenceable 中解組
參數(shù):
參數(shù)名稱 | 參數(shù)描述 |
---|---|
in | 指示用于編組的 MessageParcel 對象。 MessageParcel 是 Parcel 的子類。 |
返回:
如果解組成功,則返回 true; 否則返回 false。
Since:
1
public String toString()
從類復(fù)制的描述:對象
返回對象的字符串表示形式。 通常,toString 方法返回一個“以文本方式表示”該對象的字符串。 結(jié)果應(yīng)該是一個簡潔但信息豐富的表示,易于人們閱讀。 建議所有子類重寫此方法。
Object 類的 toString 方法返回一個字符串,該字符串由對象作為其實例的類的名稱、at 符號字符“@”和對象哈希碼的無符號十六進制表示形式組成。 換句話說,此方法返回一個等于以下值的字符串:
getClass().getName() + '@' + Integer.toHexString(hashCode())
覆蓋:
類 Object 中的 toString
返回:
對象的字符串表示形式。
Since:
4
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: