I want to delete a notification which is located on my status bar. I used Notification Manager.cancel() but it didn't work. I used cancelAll() too with the same result.
My code is:
public class NotificationListenerService extends android.service.notification.NotificationListenerService {
...
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
NotificationManager nManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nManager.cancel(sbn.getId());
nManager.cancel(sbn.getTag(), sbn.getID());
nManager.cancelAll();
}
I found more answers here on SO but none solved my issue. The sbn object is right, I print in my log all its data.
It's possible to delete an exiting notification located on the status bar with Android API < 20? (so without using cancelNotification())