新聞中心
ReminderHelper

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


咨詢
建站咨詢
