[英]Don't let user clear android notification?
There is a way that don't let user clear the notification without press button inside her? 有一种方法不让用户在没有按下按钮的情况下清除通知吗? I already set setAutoCancel(false) and it's ok, but there is a button that clear all notifications and I don't want it clear my notification cause it's important to user and he has to read it and choose an action.
我已经设置了setAutoCancel(false)并且没关系,但是有一个清除所有通知的按钮,我不希望它清除我的通知,因为它对用户很重要,他必须阅读它并选择一个动作。
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.icon)
.setContentTitle("Sync Failed")
.setContentText("Lorem ipsum dolor sit amet")
.setStyle(new NotificationCompat.BigTextStyle().bigText("Lorem ipsum dolor sit amet"))
.addAction(R.drawable.change, "Change Pass", pChangePass)
.addAction(R.drawable.remove, "Ignore", pIgnore)
.setAutoCancel(false);
mNotificationManager.notify(accountUnique, builder.build());
.setOngoing(true)
还需要加入!
For that change your last three lines code like this.. 对于那个改变你的最后三行代码像这样..
final Notification notification = builder.build();
notification.flags = Notification.FLAG_NO_CLEAR;
mNotificationManager.notify(accountUnique, notification);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.