public class ReminderHelper extends Object
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
static void |
addNotificationSlot(NotificationSlot slot) |
Creates a
NotificationSlot. |
static void |
cancelAllReminders() |
Cancel all reminders of current third part application
|
static void |
cancelReminder(int reminderId) |
Cancels a specified reminder.
|
static List<ReminderRequest> |
getValidReminders() |
Obtains all valid reminder notifications set by the current application, namely, the reminders that will
still be triggered later.
|
static int |
publishReminder(ReminderRequest reminderReq) |
Publishes a scheduled reminder.
|
static void |
removeNotificationSlot(String slotId) |
Removes a
NotificationSlot instance used by the reminder. |
public static int publishReminder(ReminderRequest reminderReq) throws ReminderManager.AppLimitExceedsException, ReminderManager.SysLimitExceedsException, RemoteException
Third-party applications can call this method to publish a scheduled reminder. After this method is called,
the timing and pop-up notification functions of the calling application will be performed by the system
service agent in the background, even when the application is frozen or exits. You can call the
ReminderRequest#setIntentAgent(String, String) method to specify whether to start the application after
the pop-up notification is taped.
The background agent maintains an ordered list of reminders for all third-party applications. The list is updated based on the scheduled trigger time of each reminder. The system starts only one most recent scheduled reminder at a time. If a reminder with a more recent trigger time is added, the new scheduled reminder will be put on top of the list. The next reminder is triggered only after the current reminder is complete.
One application can create a maximum of 30 valid reminders, and the total number of valid reminders in the system cannot exceed 2000. The minimum snooze interval for a reminder is 5 minutes.
Permissions: ohos.permission.PUBLISH_AGENT_REMINDER
reminderReq - Indicates the reminder instance to publish. This parameter cannot be null.
Otherwise, an exception will be thrown due to invalid parameters, causing the application to crash.RemoteException - Throws this exception upon an inter-process communication error.ReminderManager.AppLimitExceedsException - Throws this exception if the number of valid reminders of the
current application in the system exceeds 30 (excluding those that have expired and will not be triggered
again.)ReminderManager.SysLimitExceedsException - Throws this exception if the total number of valid reminders
in the system exceeds 2000 (excluding those that have expired and will not be triggered again.)public static void addNotificationSlot(NotificationSlot slot) throws RemoteException
NotificationSlot. You can call the ReminderRequest#setSlotId(String) method to bind
the slot for publishing a reminder.
When the application is uninstalled, all notification slots related to the application will be deleted.
slot - Indicates the NotificationSlot instance to add.RemoteException - Throws this exception upon an inter-process communication error.NotificationSlotpublic static void cancelReminder(int reminderId)
throws RemoteException
reminderId - Indicates the ID of the reminder instance to cancel.RemoteException - Throws this exception upon an inter-process communication error.public static void removeNotificationSlot(String slotId) throws RemoteException
NotificationSlot instance used by the reminder.slotId - Indicates the ID of the NotificationSlot instance to remove.RemoteException - Throws this exception upon an inter-process communication error.public static List<ReminderRequest> getValidReminders() throws RemoteException
RemoteException - Throws this exception upon an inter-process communication error.public static void cancelAllReminders()
throws RemoteException
RemoteException - Throws this exception upon an inter-process communication error.