In my project i have notification option.
Can I remove this notification in a button click?? I can cancel notification when click on this notification using the code

 checkin_notification.flags = Notification.FLAG_AUTO_CANCEL; 

but i in my application i want to clear notification after showing it. It should be in a button click.

Thanks in advance.

2 Answers

To clear all Notification of your Application you can do like,

NotificationManager notificationManager = (NotificationManager) getSystemService(Context. NOTIFICATION_SERVICE); notificationManager.cancelAll(); 

To clear a particular Notification you can do it like,

notificationManager.cancel(notification_id); 

onButton Click just Write....

mNotificationManager.cancel(SIMPLE_NOTFICATION_ID); 

You can see here and check it ....

and for clear all ...mNotificationManager.cancelAll();

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy