如何在按钮点击中清除通知

ano*_*oop 8 android

在我的项目中,我有通知选项.
我可以在按钮点击中删除此通知吗?我可以在使用代码点击此通知时取消通知

    checkin_notification.flags = Notification.FLAG_AUTO_CANCEL;
Run Code Online (Sandbox Code Playgroud)

但我在我的应用程序中我希望在显示后清除通知.它应该是一个按钮点击.

提前致谢.

Lal*_*ani 20

clear all通知您的应用程序,您可以这样做,

NotificationManager notificationManager = (NotificationManager) 
                                 getSystemService(Context.
                                                        NOTIFICATION_SERVICE);
notificationManager.cancelAll();
Run Code Online (Sandbox Code Playgroud)

要清除particular通知,您可以这样做,

notificationManager.cancel(notification_id);
Run Code Online (Sandbox Code Playgroud)


Sam*_*iya 5

onButton点击只写....

mNotificationManager.cancel(SIMPLE_NOTFICATION_ID);
Run Code Online (Sandbox Code Playgroud)

你可以在这里看到http://saigeethamn.blogspot.in/2009/09/android-developer-tutorial-for.html并检查它....

并清楚所有......mNotificationManager.cancelAll();