我想通过setAutoCancle()
方法关闭通知。
这是NotifactionExample
的代码。
@SuppressWarnings("deprecation")
protected void notifactionAlert() {
// TODO Auto-generated method stub
NotificationManager myNotifaction = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
@SuppressWarnings("deprecation")
Notification Notifaction = new Notification(R.drawable.notifaction,
"Notifaction received.", System.currentTimeMillis());
Intent notifactionIntent = new Intent(MainActivity.this, notify.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
notifactionIntent, 0);
Notifaction.setLatestEventInfo(MainActivity.this, "Notifaction.",
"you get a new notifaction...", pendingIntent);
myNotifaction.notify(9999, Notifaction);
}
我能做什么?
最佳答案
您所需要做的就是将 autoCancel 标志设置为 On。
Notifaction.flags |= Notification.FLAG_AUTO_CANCEL
关于java - Android 中自动取消通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32450875/