Issue
I have a NotificationListenerService and a:
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
Log.i(TAG,"********** onNotificationPosted");
Log.i(TAG,"ID :" + sbn.getId() + "t" + sbn.getNotification().tickerText + "t" + sbn.getPackageName());
}
How can I cancel that notification from the onNotificationPosted()
? I tried a simple manager.cancel(sbn.getId());
but it didn't worked
Solution
Try :
manager.cancel(sbn.getTag(), sbn.getId());
If this doesn't work, you can try
manager.cancel(sbn.getTag(), sbn.getId(), sbn.getUser());
You can also cancel all notifications by using :
manager.cancelAll();
Answered By - nipun.birla
Answer Checked By - Marilyn (JavaFixing Volunteer)