java.lang.Object
|---ohos.event.notification.ReminderHelper
public class ReminderHelper
extends Object
提供管理提醒的静态方法,包括发布或取消提醒、添加或删除通知槽、获取或取消当前应用的所有提醒。
Since:
6
修饰符和类型 | 方法 | 描述 |
---|---|---|
static void | addNotificationSlot(NotificationSlot slot) | 创建一个 NotificationSlot。 |
static void | cancelAllReminders() | 取消当前第三方申请的所有提醒 |
static void | cancelReminder(int reminderId) | 取消指定的提醒。 |
static ListReminderRequest | getValidReminders() | 获取当前应用设置的所有有效提醒通知,即以后仍会触发的提醒。 |
static int | publishReminder(ReminderRequest reminderReq) | 发布计划提醒。 |
static void | removeNotificationSlot(String slotId) | 删除提醒使用的 NotificationSlot 实例。 |
从类 java.lang.Object 继承的方法 |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
public static int publishReminder(ReminderRequest reminderReq) throws ReminderManager.AppLimitExceedsException, ReminderManager.SysLimitExceedsException, RemoteException
发布计划提醒。
第三方应用可以调用该方法发布定时提醒。调用此方法后,调用应用程序的定时和弹出通知功能将由系统服务代理在后台执行,即使应用程序被冻结或退出。您可以调用 ReminderRequest#setIntentAgent(String, String) 方法来指定是否在录制弹出通知后启动应用程序。
后台代理维护所有第三方应用程序的有序提醒列表。该列表根据每个提醒的预定触发时间进行更新。系统一次仅启动一个最近的预定提醒。如果添加了触发时间较近的提醒,则新的预定提醒将放在列表顶部。只有在当前提醒完成后才会触发下一个提醒。
一个应用最多可以创建30个有效提醒,系统有效提醒总数不能超过2000个。提醒的最小贪睡间隔为5分钟。
权限:ohos.permission.PUBLISH_AGENT_REMINDER
参数:
参数名称 | 参数描述 |
---|---|
reminderReq | 指示要发布的提醒实例。 此参数不能为空。 否则会因为参数无效而抛出异常,导致应用程序崩溃。 |
返回:
返回唯一的提醒 ID。
Throws:
Throw名称 | Throw描述 |
---|---|
RemoteException | 在进程间通信错误时引发此异常。 |
ReminderManager.AppLimitExceedsException | 如果系统中当前应用的有效提醒次数超过30次(不包括已过期不再触发的提醒),则抛出该异常。 |
ReminderManager.SysLimitExceedsException | 系统有效提醒总数超过2000条(不包括已过期不再触发的提醒),则抛出该异常。 |
Since:
6
public static void addNotificationSlot(NotificationSlot slot) throws RemoteException
创建一个 NotificationSlot。 您可以调用 ReminderRequest#setSlotId(String) 方法来绑定用于发布提醒的槽。
当应用程序被卸载时,所有与应用程序相关的通知槽都将被删除。
参数:
参数名称 | 参数描述 |
---|---|
slot | 指示要添加的 NotificationSlot 实例。 |
Throws:
Throw名称 | Throw描述 |
---|---|
RemoteException | 在进程间通信错误时引发此异常。 |
Since:
6
public static void cancelReminder(int reminderId) throws RemoteException
取消指定的提醒。
参数:
参数名称 | 参数描述 |
---|---|
reminderId | 指示要取消的提醒实例的 ID。 |
Throws:
Throw名称 | Throw描述 |
---|---|
RemoteException | 在进程间通信错误时引发此异常。 |
Since:
6
public static void removeNotificationSlot(String slotId) throws RemoteException
删除提醒使用的 NotificationSlot 实例。
参数:
参数名称 | 参数描述 |
---|---|
slotId | 指示要删除的 NotificationSlot 实例的 ID。 |
Throws:
Throw名称 | Throw描述 |
---|---|
RemoteException | 在进程间通信错误时引发此异常。 |
Since:
6
public static ListReminderRequest getValidReminders() throws RemoteException
获取当前应用设置的所有有效提醒通知,即以后仍会触发的提醒。 如果不再触发提醒,则不视为有效提醒。
返回:
返回一个数组列表,其中包含当前应用程序设置的所有有效提醒通知。
Throws:
Throw名称 | Throw描述 |
---|---|
RemoteException | 在进程间通信错误时引发此异常。 |
Since:
6
public static void cancelAllReminders() throws RemoteException
取消当前第三方申请的所有提醒
Throws:
Throw名称 | Throw描述 |
---|---|
RemoteException | 在进程间通信错误时引发此异常。 |
Since:
6
Configurationjava.lang.Object |---ohos.global.configuration.Configurationpublic class Configurationextends Object提供资...
Closeablepublic interface Closeableextends AutoCloseableCloseable 是可以关闭的数据的源或目标。 调用 close 方法来释放对象...
FileDescriptorjava.lang.Object |---java.io.FileDescriptorpublic final class FileDescriptorextends Object文件描述符类的实...
FilterReaderjava.lang.Object |---java.io.Reader |---|---java.io.FilterReaderpublic abstract class FilterReaderextends Re...
SequenceInputStreamjava.lang.Object |---java.io.InputStream |---|---java.io.SequenceInputStreampublic class SequenceInpu...
EOFExceptionjava.lang.Object |---java.lang.Throwable |---|---java.lang.Exception |---|---|---java.io.IOException |---|--...
绘图接口和方法canvasContext.clearActions (不推荐使用)清空绘图上下文的绘图动作。绘图接口和方法...
Document.set替换更新一条记录函数签名如下:function set(options: object): PromiseResult参数说明options为必填参数,是一个...
db.RegExp从基础库 2.3.2 开始(wx-server-sdk 从 0.0.23 开始),数据库支持正则表达式查询,开发者可以在查询语句中使用 JavaS...
downloadFile从云存储空间下载文件请求参数字段说明数据类型默认值必填fileID云文件 IDString-YPromise 返回参数字段说明数据类...