android 让通知不被清除或者点击后不消失

来源:互联网 发布:java导出excel换行 编辑:程序博客网 时间:2024/05/14 11:21

转自:http://blog.csdn.net/sergeycao/article/details/8151957


APP发送通知后,点击clear按钮,如何让通知不被清除?或者点击通知后,通知不消失?

APP发送通知时,通知需要添加flag:

Notification notification;
notification.flags |= Notification.FLAG_ONGOING_EVENT;
或者
notification.flags |= Notification.FLAG_NO_CLEAR;


PendingIntent.FLAG_CANCEL_CURRENT;
PendingIntent.FLAG_NO_CREATE;     
PendingIntent.FLAG_ONE_SHOT;      
PendingIntent.FLAG_UPDATE_CURRENT;