新聞中心
ReminderHelper

java.lang.Object
|---ohos.event.notification.ReminderHelper
public class ReminderHelper
extends Object提供管理提醒的靜態(tài)方法,包括發(fā)布或取消提醒、添加或刪除通知槽、獲取或取消當前應用的所有提醒。
Since:
6
方法總結(jié)
| 修飾符和類型 | 方法 | 描述 |
|---|---|---|
| static void | addNotificationSlot(NotificationSlot slot) | 創(chuàng)建一個 NotificationSlot。 |
| static void | cancelAllReminders() | 取消當前第三方申請的所有提醒 |
| static void | cancelReminder(int reminderId) | 取消指定的提醒。 |
| static ListReminderRequest | getValidReminders() | 獲取當前應用設(shè)置的所有有效提醒通知,即以后仍會觸發(fā)的提醒。 |
| static int | publishReminder(ReminderRequest reminderReq) | 發(fā)布計劃提醒。 |
| static void | removeNotificationSlot(String slotId) | 刪除提醒使用的 NotificationSlot 實例。 |
| 從類 java.lang.Object 繼承的方法 |
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
方法詳情
publishReminder
public static int publishReminder(ReminderRequest reminderReq) throws ReminderManager.AppLimitExceedsException, ReminderManager.SysLimitExceedsException, RemoteException
發(fā)布計劃提醒。
第三方應用可以調(diào)用該方法發(fā)布定時提醒。調(diào)用此方法后,調(diào)用應用程序的定時和彈出通知功能將由系統(tǒng)服務(wù)代理在后臺執(zhí)行,即使應用程序被凍結(jié)或退出。您可以調(diào)用 ReminderRequest#setIntentAgent(String, String) 方法來指定是否在錄制彈出通知后啟動應用程序。
后臺代理維護所有第三方應用程序的有序提醒列表。該列表根據(jù)每個提醒的預定觸發(fā)時間進行更新。系統(tǒng)一次僅啟動一個最近的預定提醒。如果添加了觸發(fā)時間較近的提醒,則新的預定提醒將放在列表頂部。只有在當前提醒完成后才會觸發(fā)下一個提醒。
一個應用最多可以創(chuàng)建30個有效提醒,系統(tǒng)有效提醒總數(shù)不能超過2000個。提醒的最小貪睡間隔為5分鐘。
權(quán)限:ohos.permission.PUBLISH_AGENT_REMINDER
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| reminderReq | 指示要發(fā)布的提醒實例。 此參數(shù)不能為空。 否則會因為參數(shù)無效而拋出異常,導致應用程序崩潰。 |
返回:
返回唯一的提醒 ID。
Throws:
| Throw名稱 | Throw描述 |
|---|---|
| RemoteException | 在進程間通信錯誤時引發(fā)此異常。 |
| ReminderManager.AppLimitExceedsException | 如果系統(tǒng)中當前應用的有效提醒次數(shù)超過30次(不包括已過期不再觸發(fā)的提醒),則拋出該異常。 |
| ReminderManager.SysLimitExceedsException | 系統(tǒng)有效提醒總數(shù)超過2000條(不包括已過期不再觸發(fā)的提醒),則拋出該異常。 |
Since:
6
addNotificationSlot
public static void addNotificationSlot(NotificationSlot slot) throws RemoteException
創(chuàng)建一個 NotificationSlot。 您可以調(diào)用 ReminderRequest#setSlotId(String) 方法來綁定用于發(fā)布提醒的槽。
當應用程序被卸載時,所有與應用程序相關(guān)的通知槽都將被刪除。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| slot | 指示要添加的 NotificationSlot 實例。 |
Throws:
| Throw名稱 | Throw描述 |
|---|---|
| RemoteException | 在進程間通信錯誤時引發(fā)此異常。 |
Since:
6
cancelReminder
public static void cancelReminder(int reminderId) throws RemoteException
取消指定的提醒。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| reminderId | 指示要取消的提醒實例的 ID。 |
Throws:
| Throw名稱 | Throw描述 |
|---|---|
| RemoteException | 在進程間通信錯誤時引發(fā)此異常。 |
Since:
6
removeNotificationSlot
public static void removeNotificationSlot(String slotId) throws RemoteException
刪除提醒使用的 NotificationSlot 實例。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| slotId | 指示要刪除的 NotificationSlot 實例的 ID。 |
Throws:
| Throw名稱 | Throw描述 |
|---|---|
| RemoteException | 在進程間通信錯誤時引發(fā)此異常。 |
Since:
6
getValidReminders
public static ListReminderRequest getValidReminders() throws RemoteException
獲取當前應用設(shè)置的所有有效提醒通知,即以后仍會觸發(fā)的提醒。 如果不再觸發(fā)提醒,則不視為有效提醒。
返回:
返回一個數(shù)組列表,其中包含當前應用程序設(shè)置的所有有效提醒通知。
Throws:
| Throw名稱 | Throw描述 |
|---|---|
| RemoteException | 在進程間通信錯誤時引發(fā)此異常。 |
Since:
6
cancelAllReminders
public static void cancelAllReminders() throws RemoteException
取消當前第三方申請的所有提醒
Throws:
| Throw名稱 | Throw描述 |
|---|---|
| RemoteException | 在進程間通信錯誤時引發(fā)此異常。 |
Since:
6
網(wǎng)頁名稱:創(chuàng)新互聯(lián)鴻蒙OS教程:鴻蒙OS ReminderHelper
瀏覽地址:http://www.5511xx.com/article/djgsicc.html


咨詢
建站咨詢
