鸿蒙OS开发文档 第15页

鸿蒙OS ReminderRequestAlarm

ReminderRequestAlarm java.lang.Object |—ohos.event.notification.ReminderRequest |—|—ohos.event.notification.ReminderRequestAlarm public class ReminderRequestAlarm extends ReminderRequest 用于创建闹钟提醒的 ReminderRequest 子类。 您可以使用该类在特定日期或每周特定日期的指定时间(精确到分钟)发布警报提醒。 Since: 6 嵌套类摘要 从接口 ohos.utils.Sequenceable 继承的嵌套类/接口 Sequenceable.ProducerT 字段摘要 从类 ohos.event.notification.ReminderRequest 继承的字段 ACTION_BUTTON_TYPE_CLOSE, ACTION_BUTTON_TYPE_SNOOZE 构造函数摘要 构造函数 描述 ReminderRequestAlarm(int hour, int minute, int[] daysOfWeek) 用于创建 ReminderRequestAlarm 实例的构造函数。 方法总结 修饰符和类型 方法 描述 boolean marshalling(Parcel out) 将此 Sequenceable 对象编组为 Parcel。 boolean unmarshalling(Parcel in) 从 Parcel 中解组此 Sequenceable 对象。 从类 java.lang.Object 继承的方法 clone, finalize, getClass, notify, notifyAll, wait, wait, wait 从类 ohos.event.notification.ReminderRequest 继承的方法 compareTo, equals, getContent, getExpiredContent, getNotificationId, getRingDuration, getSlotId, getSnoozeContent, getSnoozeTimes, getTimeInterval, getTitle, hashCode, setActionButton, setContent, setExpiredContent, setIntentAgent, setMaxScreenIntentAgent, setNotificationId, setRingDuration, setSlotId, setSnoozeContent, setSnoozeTimes, setTimeInterval, setTitle, toString 从接口 ohos.utils.Sequenceable 继承的方法 hasFileDescriptor 构造函数详细信息 ReminderRequestAlarm public ReminderRequestAlarm(int hour, int minute, int[] daysOfWeek) 用于创建 ReminderRequestAlarm 实例的构造函数。 警报提醒将在指定时间触发。 确保输入参数满足以下要求。 否则,应用程序可能会因为非法参数异常而崩溃。 hour 的值必须大于等于 0 小于等于 23。 minute 的值必须大于等于 0 小于等于 59。 daysOfWeek 数组的长度不能大于 7。 参数: 参数名称 参数描述 hour 指示此警报提醒的小时数。 取值范围为 0 到 23。 minute 指示此警报提醒的分钟。 取值范围为 0 到 59。 daysOfWeek 表示一周中的哪几天触发此警报提醒。 例如,值 {1, 3} 表示提醒将在每周一和周三触发。 默认情况下,此提醒不会被延后。 您可以调用 ReminderRequest.setTimeInterval(long) 来设置贪睡间隔。 如果设置了打盹间隔,该提醒会默认打盹3次。 您可以调用 ReminderRequest.setSnoozeTimes(int) 来更改贪睡时间。 Since: 6 方法详情 marshalling public boolean marshalling(Parcel out) 从接口复制的描述:Sequenceable 将此 Sequenceable 对象编组为 Parcel。 指定者: 接口 Sequenceable 中的编组 覆盖: 在类 ReminderRequest 中编组 参数: 参数名称 参数描述 out 指示将 Sequenceable 对象编组到的 Parcel 对象。 返回: 如果编组成功,则返回 true; 否则返回 false。...

鸿蒙OS ReminderRequest

ReminderRequest java.lang.Object |—ohos.event.notification.ReminderRequest public abstract class ReminderRequest extends Object implements Sequenceable, Comparable<ReminderRequest> 让后台代理代表第三方应用程序发布提醒的基类。 第三方应用程序可以使用此类来创建计划提醒,包括用于倒计时、日历事件和活动闹钟的提醒。 调用该类后,调用应用程序的定时和弹出通知功能将由系统服务代理在后台执行,即使应用程序被冻结或退出。 您可以调用 ReminderRequest#setIntentAgent(String, String) 方法来指定是否在录制弹出通知后启动应用程序。 Since: 6 嵌套类摘要 从接口 ohos.utils.Sequenceable 继承的嵌套类/接口 Sequenceable.ProducerT 字段摘要 修饰符和类型 字段 描述 static int ACTION_BUTTON_TYPE_CLOSE ActionButton 类型,表示该动作按钮用于关闭提醒的通知。 static int ACTION_BUTTON_TYPE_SNOOZE ActionButton 类型,表示该动作按钮用于打盹提醒。 方法总结 修饰符和类型 方法 描述 int compareTo(ReminderRequest other) 按 triggerTime(RTC) 的升序排序。 boolean equals(Object obj) 指示其他对象是否“等于”这个对象。 String getContent() 获取本次提醒的内容。 String getExpiredContent() 获取该提醒过期时显示的扩展内容。 int getNotificationId() 获取此提醒使用的通知 ID。 long getRingDuration() 获取为此提醒配置的响铃或振动持续时间。 String getSlotId() 获取本次提醒使用的槽位ID。 String getSnoozeContent() 获取该提醒打盹时显示的扩展内容。 int getSnoozeTimes() 获取此提醒将被自动延后的次数。 long getTimeInterval() 获取本次提醒的贪睡间隔。 String getTitle() 获取此提醒的标题。 int hashCode() 返回对象的哈希码值。 boolean marshalling(Parcel out) 将此 Sequenceable 对象编组为 Parcel。 ReminderRequest setActionButton(String title, int type) 在此提醒的弹出通知屏幕中添加一个 NotificationActionButton。 ReminderRequest setContent(String content) 设置此提醒的内容。 ReminderRequest setExpiredContent(String expiredContent) 设置此提醒到期时显示的扩展内容。 ReminderRequest setIntentAgent(String pkgName, String abilityName) 设置有关在用户点击为此提醒显示的通知后重定向到的目标能力的信息。 ReminderRequest setMaxScreenIntentAgent(String pkgName, String abilityName) 设置在设备不使用时根据给定的 maxScreenIntentAgent 启动的能力,而不是在状态栏中显示此提醒的通知。 ReminderRequest setNotificationId(int notificationId) 设置此提醒的通知 ID。 ReminderRequest setRingDuration(long ringDurationInSeconds) 设置此提醒的响铃或振动持续时间,以秒为单位。 ReminderRequest setSlotId(String slotId) 设置此提醒的槽 ID。 ReminderRequest setSnoozeContent(String snoozeContent) 设置此提醒暂停时显示的扩展内容。 ReminderRequest setSnoozeTimes(int snoozeTimes) 设置此提醒的贪睡次数。v ReminderRequest setTimeInterval(long timeIntervalInSeconds) 设置此提醒的贪睡间隔,以秒为单位。 ReminderRequest setTitle(String title) 设置此提醒的标题。 String toString() 返回对象的字符串表示形式。 boolean unmarshalling(Parcel in)...

鸿蒙OS ReminderManager.SysLimitExceedsException

ReminderManager.SysLimitExceedsException java.lang.Object |—java.lang.Throwable |—|—java.lang.Exception |—|—|—ohos.event.notification.ReminderManager.SysLimitExceedsException public class ReminderManager.SysLimitExceedsException extends Exception 全系统有效提醒次数超过限制值ReminderDataManager#MAX_NUM_REMINDER_LIMIT_SYSTEM时抛出该异常 方法总结 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 从类 java.lang.Throwable 继承的方法 addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString

鸿蒙OS ReminderManager.AppLimitExceedsException

ReminderManager.AppLimitExceedsException java.lang.Object |—java.lang.Throwable |—|—java.lang.Exception |—|—|—ohos.event.notification.ReminderManager.AppLimitExceedsException public class ReminderManager.AppLimitExceedsException extends Exception 当前应用的有效提醒次数超过限制值 ReminderDataManager#MAX_NUM_REMINDER_LIMIT_APP 时抛出此异常 方法总结 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 从类 java.lang.Throwable 继承的方法 addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString

鸿蒙OS ReminderManager

ReminderManager java.lang.Object |—ohos.event.notification.ReminderManager public class ReminderManager extends Object 为后台代理服务功能定义常量。 Since: 6 嵌套类摘要 修饰符和类型 类 描述 class ReminderManager.AppLimitExceedsException 当前应用的有效提醒次数超过限制值 ReminderDataManager#MAX_NUM_REMINDER_LIMIT_APP 时抛出此异常 class ReminderManager.SysLimitExceedsException 全系统有效提醒次数超过限制值ReminderDataManager#MAX_NUM_REMINDER_LIMIT_SYSTEM时抛出该异常 方法总结 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

鸿蒙OS ReminderHelper

ReminderHelper 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 方法详情 publishReminder 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 addNotificationSlot public static void addNotificationSlot(NotificationSlot slot) throws RemoteException 创建一个 NotificationSlot。 您可以调用 ReminderRequest#setSlotId(String) 方法来绑定用于发布提醒的槽。 当应用程序被卸载时,所有与应用程序相关的通知槽都将被删除。 参数: 参数名称 参数描述 slot 指示要添加的 NotificationSlot 实例。 Throws: Throw名称 Throw描述 RemoteException 在进程间通信错误时引发此异常。 Since: 6 cancelReminder public static void cancelReminder(int reminderId) throws RemoteException 取消指定的提醒。 参数: 参数名称 参数描述 reminderId 指示要取消的提醒实例的 ID。 Throws: Throw名称 Throw描述 RemoteException 在进程间通信错误时引发此异常。...

鸿蒙OS NotificationUserInput.Builder

NotificationUserInput.Builder java.lang.Object |—ohos.event.notification.NotificationUserInput.Builder public static final class NotificationUserInput.Builder extends Object NotificationUserInput 对象的构建器类。 Since: 3 构造函数摘要 构造函数 描述 Builder(String inputKey) 用于创建用于创建 NotificationUserInput 对象的 Builder 实例的构造函数。 方法总结 修饰符和类型 方法 描述 NotificationUserInput.Builder addAdditionalData(PacMap pacMap) 将附加数据添加到此 Builder。 NotificationUserInput build() 使用所有设置创建一个新的 NotificationUserInput 对象。 NotificationUserInput.Builder setEditType(NotificationConstant.InputEditType editType) 设置此 NotificationUserInput 对象提供的选项的编辑类型。 NotificationUserInput.Builder setOptions(ListString options) 设置提供给用户的选项以满足用户输入需求。 NotificationUserInput.Builder setPermitFreeFormInput(boolean permitFreeFormInput) 设置用户是否可以输入任意文本值。 NotificationUserInput.Builder setPermitMimeTypes(String mimeType, boolean doPermit) 设置用户是否可以输入给定 MIME 类型的值。 NotificationUserInput.Builder setTag(String tag) 设置从用户收集此输入时显示给用户的标签。 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 构造函数详细信息 Builder public Builder(String inputKey) 用于创建用于创建 NotificationUserInput 对象的 Builder 实例的构造函数。 参数: 参数名称 参数描述 inputKey 指示从用户收集输入时用于识别此输入的 PacMap 键。 Throws: Throw名称 Throw描述 IllegalArgumentException 如果 inputKey 为 null,则引发此异常。 Since: 3 方法详情 setTag public NotificationUserInput.Builder setTag(String tag) 设置从用户收集此输入时显示给用户的标签。 参数: 参数名称 参数描述 tag 表示要显示的标签。 返回: 返回此 Builder 对象。 Since: 3 setOptions public NotificationUserInput.Builder setOptions(ListString options) 设置提供给用户的选项以满足用户输入需求。 所有选项都显示在一行中。 由于篇幅有限,如果选项太长或选项太多,可能会隐藏部分或全部选项。 参数: 参数名称 参数描述 options 指示要为用户输入提供的预定义选项列表。 返回: 返回此 Builder 对象。 Since: 3 setPermitMimeTypes public NotificationUserInput.Builder setPermitMimeTypes(String mimeType, boolean doPermit) 设置用户是否可以输入给定 MIME 类型的值。 参数: 参数名称 参数描述...

鸿蒙OS NotificationUserInput

NotificationUserInput java.lang.Object |—ohos.event.notification.NotificationUserInput public class NotificationUserInput extends Object implements Sequenceable 定义用户输入,它将与发送的 IntentAgent 中的意图一起传递。 您应该始终使用 NotificationUserInput.Builder 创建此类的实例。 您可以调用 NotificationActionButton.Builder#addNotificationUserInput(NotificationUserInput) 将 NotificationUserInput 对象添加到 NotificationActionButton。 Since: 3 嵌套类摘要 修饰符和类型 类 描述 static class NotificationUserInput.Builder NotificationUserInput 对象的构建器类。 从接口 ohos.utils.Sequenceable 继承的嵌套类/接口 Sequenceable.ProducerT 字段摘要 修饰符和类型 字段 描述 static Sequenceable.ProducerNotificationUserInput PRODUCER 从 Parcel 创建 NotificationUserInput 实例。 方法总结 修饰符和类型 方法 描述 static void addInputsToIntent(ListNotificationUserInput userInputs, Intent intent, PacMap pacMap) 将 NotificationUserInput 对象列表添加到 Intent。 static void addMimeInputToIntent(NotificationUserInput userInput, Intent intent, MapString,Uri results) 将指定 MIME 类型的给定 NotificationUserInput 对象添加到 Intent。 PacMap getAdditionalData() 获取包含在此 NotificationUserInput 对象中的附加数据。 int getEditType() 获取此 NotificationUserInput 对象提供的选项的编辑类型。 String getInputKey() 获取此 NotificationUserInput 对象的键。 static PacMap getInputsFromIntent(Intent intent) 从指定的 ohos.aafwk.content.Intent 获取输入文本结果。 static int getInputsSource(Intent intent) 获取此 NotificationUserInput 对象的输入源。 static MapString,Uri getMimeInputsFromIntent(Intent intent, String inputKey) 从指定的 ohos.aafwk.content.Intent 获取特定 MIME 类型的输入结果。 ListString getOptions() 获取提供给用户的选项以满足用户输入需求。 SetString getPermitMimeTypes() 获取此 NotificationUserInput 对象允许的 MIME 类型。 String getTag() 当从用户那里收集这个输入时,获取要显示给用户的标签。 boolean isMimeTypeOnly() 检查此 NotificationUserInput 对象是否仅允许特定 MIME 类型的值。 boolean isPermitFreeFormInput() 检查用户是否可以为此 NotificationUserInput 对象提供任意值。 boolean marshalling(Parcel out) 将 NotificationUserInput 对象编组到 Parcel 中。 static void setInputsSource(Intent intent, NotificationConstant.InputsSource source) 设置此 NotificationUserInput 对象的输入源。 String toString() 返回对象的字符串表示形式。 boolean unmarshalling(Parcel in) 从 Parcel 中解组 NotificationUserInput 对象。 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 从接口 ohos.utils.Sequenceable 继承的方法 hasFileDescriptor 字段详细信息 PRODUCER public static final Sequenceable.ProducerNotificationUserInput PRODUCER 从 Parcel 创建 NotificationUserInput 实例。 Since: 4 方法详情...

鸿蒙OS NotificationSubscriber

NotificationSubscriber java.lang.Object |—ohos.event.notification.NotificationSubscriber public abstract class NotificationSubscriber extends Object 提供当订阅者收到新通知或通知被取消时将被回调的方法。 NotificationSubscriber 是一个抽象类。 如果你想在你的应用程序中监听通知,你必须首先继承这个类并实现相关的方法。 例如,如果您想在收到通知时收到通知,请覆盖 onConsumed(ohos.event.notification.NotificationRequest); 如果您想在取消通知时收到通知,请覆盖 onCanceled(ohos.event.notification.NotificationRequest) 方法。 请注意,您的应用程序必须具有系统级权限才能订阅通知。 Since: 1 构造函数摘要 构造函数 描述 NotificationSubscriber() 方法总结 修饰符和类型 方法 描述 abstract void onCanceled(NotificationRequest request) 取消通知时回调。 abstract void onCanceled(NotificationRequest request, NotificationSortingMap sortingMap, int deleteReason) 取消通知时回调。 abstract void onConnected() 当订阅者连接到高级通知服务 (ANS) 时回调。 abstract void onConsumed(NotificationRequest request) 当订阅者收到新通知时回调。 abstract void onConsumed(NotificationRequest request, NotificationSortingMap sortingMap) 当订阅者收到新通知时回调。 abstract void onDied() 当与 ANS 的连接中断时回调。 abstract void onDisConnect() 当订阅者与 ANS 断开连接时回调。 abstract void onDisturbModeChanged(int disturbMode) 当请勿打扰模式类型更改时调用。 abstract void onUpdate(NotificationSortingMap sortingMap) 当前通知的排名信息发生变化时回调。 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 构造函数详细信息 NotificationSubscriber public NotificationSubscriber() 方法详情 onConsumed public abstract void onConsumed(NotificationRequest request) 当订阅者收到新通知时回调。 您需要继承 NotificationSubscriber 类并重写该方法来订阅和接收通知。 参数: 参数名称 参数描述 request 表示接收到的 NotificationRequest 对象。 Since: 1 onConsumed public abstract void onConsumed(NotificationRequest request, NotificationSortingMap sortingMap) 当订阅者收到新通知时回调。 您需要继承 NotificationSubscriber 类并重写该方法来订阅和接收通知。 参数: 参数名称 参数描述 request 表示接收到的 NotificationRequest 对象。 sortingMap 表示当前订阅者获取通知排名信息所使用的排序图。 Since: 2 onCanceled public abstract void onCanceled(NotificationRequest request, NotificationSortingMap sortingMap, int deleteReason) 取消通知时回调。 如果要在取消通知时收到通知,则需要继承 NotificationSubscriber 类并重写此方法。 参数: 参数名称 参数描述...

鸿蒙OS NotificationSubscribeInfo

NotificationSubscribeInfo java.lang.Object |—ohos.event.notification.NotificationSubscribeInfo public class NotificationSubscribeInfo extends Object implements Sequenceable 设置发布者的过滤条件以订阅所需的通知。 在 NotificationSubscribeInfo 对象中设置过滤条件后,您可以使用它仅订阅或取消订阅来自满足过滤条件的发布者的通知。 只有系统应用可以订阅或取消订阅通知。 Since: 1 嵌套类摘要 从接口 ohos.utils.Sequenceable 继承的嵌套类/接口 Sequenceable.ProducerT 字段摘要 修饰符和类型 字段 描述 static Sequenceable.ProducerNotificationSubscribeInfo PRODUCER 从 Parcel 创建 NotificationSubscribeInfo 实例。 构造函数摘要 构造函数 描述 NotificationSubscribeInfo() 用于创建空 NotificationSubscribeInfo 实例的默认构造函数。 NotificationSubscribeInfo(NotificationSubscribeInfo subscribeInfo) 用于通过从现有参数复制参数来创建 NotificationSubscribeInfo 实例的构造函数。 方法总结 修饰符和类型 方法 描述 NotificationSubscribeInfo addAppName(String appName) 设置单个应用名称作为过滤条件,即订阅该应用的通知。 NotificationSubscribeInfo addAppNames(String[] appNames) 设置多个应用名称作为过滤条件,即订阅这些应用的通知。 SetString getAppNames() 获取当前 NotificationSubscribeInfo 对象中的应用程序名称。 boolean marshalling(Parcel out) 将 NotificationSubscribeInfo 对象编组到 Parcel 中。 String toString() 返回对象的字符串表示形式。 boolean unmarshalling(Parcel in) 从 Parcel 中解组 NotificationSubscribeInfo 对象。 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 从接口 ohos.utils.Sequenceable 继承的方法 hasFileDescriptor 字段详细信息 PRODUCER public static final Sequenceable.ProducerNotificationSubscribeInfo PRODUCER 从 Parcel 创建 NotificationSubscribeInfo 实例。 Since: 4 构造函数详细信息 NotificationSubscribeInfo public NotificationSubscribeInfo() 用于创建空 NotificationSubscribeInfo 实例的默认构造函数。 Since: 1 NotificationSubscribeInfo public NotificationSubscribeInfo(NotificationSubscribeInfo subscribeInfo) 用于通过从现有参数复制参数来创建 NotificationSubscribeInfo 实例的构造函数。 参数: 参数名称 参数描述 subscribeInfo 指示 NotificationSubscribeInfo 对象。 Since: 1 方法详情 getAppNames public SetString getAppNames() 获取当前 NotificationSubscribeInfo 对象中的应用程序名称。 应用程序名称可以通过调用 addAppName(java.lang.String) 或 [addAppNames(java.lang.String]) 来设置。 返回: 返回应用程序名称集。 Since: 1...