How to remove notification from notification bar programmatically in android?

后端 未结 4 730
旧时难觅i
旧时难觅i 2020-12-04 11:56

Anybody have idea how can we remove notification from application programmatically which is called using Pending intent.

I have used to cancel notification using fol

4条回答
  •  时光取名叫无心
    2020-12-04 12:19

    Maybe try this :

    NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancel(NOTIFICATION_ID);
    

    OR, you can also do this to cancel all notifications in given context:

    notificationManager.cancelAll();
    

    See this link to the documentation : NotificationManager

提交回复
热议问题