NotificationListenerService cancelNotification won't work for notifications with reply-actions

542 views Asked by At

Background: There are 2 type of notifications.... Plain ones (The old traditional type) and the ones since Lolipop that can have "reply" actions.

I made a NotificationListenerService that can dismiss notifications (from any other app, not only mine) using command cancelNotification only if the notification is the old "plain" type. But if the notification has "reply" actions (android wear pending intents), when I execute the cancelNotification(ID) the notification is removed and "re-posted" reapearing on the notification bar. I can endlessly try to remove the notifications and they always come again.

String removing = "example ID";

@Override
public void onNotificationPosted(StatusBarNotification sbn){
  if (sbn.getKey().equals(removing))
    {
        Log.e("INTENT","DISMISS MESSAGE");

        super.cancelNotification(sbn.getKey());
        super.cancelNotification(sbn.getPackageName(), sbn.getTag(), sbn.getId());

        removing = "";
        return;
    } 

both commands (only one parameter and 3 parameters) behave the same way.

Is there another way to dismiss a message that is specting a "wearableExtender" reply?

All prerequisites are met:

Added -> android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" Also 'Notification Access' is active and checked.

0

There are 0 answers