赞
踩
接口名 | 描述 |
---|---|
NotificationSlot(String id, String name, int level) | 构造NotificationSlot |
setLevel(int level) | 设置NotificationSlot的级别 |
setName(String name) | 设置NotificationSlot的命名 |
setDescription(String description) | 设置NotificationSlot的描述信息 |
enableBypassDnd(boolean bypassDnd) | 设置是否绕过系统的免打扰模式 |
setEnableVibration(boolean vibration) | 设置收到通知时是否使能振动 |
setLockscreenVisibleness(int visibleness) | 设置在锁屏场景下,收到通知后是否显示,以及显示的效果 |
setEnableLight(boolean isLightEnabled) | 设置收到通知时是否开启呼吸灯,前提是当前硬件支持呼吸灯 |
setLedLightColor(int color) | 设置收到通知时的呼吸灯颜色 |
setSlotGroup(String groupId) | 绑定当前NotificationSlot到一个NotificationSlot组 |
接口名 | 描述 |
---|---|
NotificationRequest() | 构建一个通知 |
NotificationRequest(int notificationId) | 构建一个通知,指定通知的id。通知的Id在应用内容具有唯一性,如果不指定,默认为0 |
setNotificationId(int notificationId) | 设置当前通知id |
setAutoDeletedTime(long time) | 设置通知自动取消的时间戳 |
setContent(NotificationRequest.NotificationContent content) | 设置通知的具体内容 |
setDeliveryTime(long deliveryTime) | 设置通知分发的时间戳 |
setSlotId(String slotId) | 设置通知的NotificationSlot id |
setTapDismissed(boolean tapDismissed) | 设置通知在用户点击后是否自动取消 |
setLittleIcon(PixelMap smallIcon) | 设置通知的小图标,在通知左上角显示 |
setBigIcon(PixelMap bigIcon) | 设置通知的大图标,在通知的右边显示 |
setGroupValue(String groupValue) | 设置分组通知,相同分组的通知在通知栏显示时,将会折叠在一组应用中显示 |
addActionButton(NotificationActionButton actionButton) | 设置通知添加通知ActionButton |
setIntentAgent(IntentAgent agent) | 设置通知承载指定的IntentAgent,在通知中实现即将触发的事件 |
类名 | 接口名 | 描述 |
---|---|---|
NotificationNormalContent | setTitle(String title) | 设置通知标题 |
NotificationNormalContent | setText(String text) | 设置通知内容 |
NotificationNormalContent | setAdditionalText(String additionalText) | 设置通知次要内容,是对通知内容的补充 |
NotificationPictureContent | setBriefText(String briefText) | 设置通知概要内容,是对通知内容的总结 |
NotificationPictureContent | setExpandedTitle(String expandedTitle) | 设置附加图片的通知展开时的标题 |
NotificationPictureContent | setBigPicture(PixelMap bigPicture) | 设置通知的图片内容,附加在setText(String text)下方 |
NotificationLongTextContent | setLongText(String longText) | 设置通知的长文本 |
NotificationConversationalContent | setConversationTitle(String conversationTitle) | 设置社交通知的标题 |
NotificationConversationalContent | addConversationalMessage(ConversationalMessage message) | 通知添加一条消息 |
NotificationMultiLineContent | addSingleLine(String line) | 在当前通知中添加一行文本 |
NotificationMediaContent | setAVToken(AVToken avToken) | 将媒体通知绑定指定的AVToken |
NotificationMediaContent | setShownActions(int[] actions) | 设置媒体通知待展示的按钮 |
接口名 | 描述 |
---|---|
publishNotification(NotificationRequest request) | 发布一条通知 |
publishNotification(String tag, NotificationRequest request) | 发布一条带TAG的通知 |
cancelNotification(int notificationId) | 取消指定的通知 |
cancelNotification(String tag, int notificationId) | 取消指定的带TAG的通知 |
cancelAllNotifications() | 取消之前发布的所有通知 |
addNotificationSlot(NotificationSlot slot) | 创建一个NotificationSlot |
getNotificationSlot(String slotId) | 获取NotificationSlot |
removeNotificationSlot(String slotId) | 删除一个NotificationSlot |
getActiveNotifications() | 获取当前应用发的活跃通知 |
getActiveNotificationNums() | 获取系统中当前应用发的活跃通知的数量 |
setNotificationBadgeNum(int num) | 设置通知的角标 |
setNotificationBadgeNum() | 设置当前应用中活跃状态通知的数量在角标显示 |
NotificationSlot slot = new NotificationSlot("slot_001", "slot_default", NotificationSlot.LEVEL_MIN); // 创建notificationSlot对象
slot.setDescription("NotificationSlotDescription");
slot.setEnableVibration(true); // 设置振动提醒
slot.setLockscreenVisibleness(NotificationRequest.VISIBLENESS_TYPE_PUBLIC);// 设置锁屏模式
slot.setEnableLight(true); // 设置开启呼吸灯提醒
slot.setLedLightColor(Color.RED.getValue());// 设置呼吸灯的提醒颜色
try {
NotificationHelper.addNotificationSlot(slot);
} catch (RemoteException ex) {
HiLog.error(LABEL, "Exception occurred during addNotificationSlot invocation.");
}
int notificationId = 1;
NotificationRequest request = new NotificationRequest(notificationId);
request.setSlotId(slot.getId());
String title = "title";
String text = "There is a normal notification content.";
NotificationNormalContent content = new NotificationNormalContent();
content.setTitle(title)
.setText(text);
NotificationRequest.NotificationContent notificationContent = new NotificationRequest.NotificationContent(content);
request.setContent(notificationContent); // 设置通知的内容
try {
NotificationHelper.publishNotification(request);
} catch (RemoteException ex) {
HiLog.error(LABEL, "Exception occurred during publishNotification invocation.");
}
int notificationId = 1;
try {
NotificationHelper.cancelNotification(notificationId);
} catch (RemoteException ex) {
HiLog.error(LABEL, "Exception occurred during cancelNotification invocation.");
}
try {
NotificationHelper.cancelAllNotifications();
} catch (RemoteException ex) {
HiLog.error(LABEL, "Exception occurred during cancelAllNotifications invocation.");
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。