Android NotificationListenerService取消通知

Android NotificationListenerService取消通知,android,notifications,Android,Notifications,我有一个NotificationListener服务和一个: @Override public void onNotificationPosted(StatusBarNotification sbn) { Log.i(TAG,"********** onNotificationPosted"); Log.i(TAG,"ID :" + sbn.getId() + "t" + sbn.getNotification().tickerText + "t" + sbn.getPacka

我有一个NotificationListener服务和一个:

@Override
public void onNotificationPosted(StatusBarNotification sbn) {
    Log.i(TAG,"**********  onNotificationPosted");
    Log.i(TAG,"ID :" + sbn.getId() + "t" + sbn.getNotification().tickerText + "t" + sbn.getPackageName());
}
如何从
onNotificationPosted()
取消该通知?我尝试了一个简单的
manager.cancel(sbn.getId())但它不起作用

尝试:
manager.cancel(sbn.getTag(),sbn.getId())

如果这不起作用,您可以尝试
manager.cancel(sbn.getTag(),sbn.getId(),sbn.getUser())

您还可以使用取消所有通知:

manager.cancelAll()

您能否演示如何将通知传递给通知管理器?这是firebase创建的后台通知。所以我没有创造。。当我的应用程序在后台时,firebase只需在我监听我发布的firebase通知后创建一个通知,然后我需要在通知区域中清除该通知:sbn.getNotification().contentIntent.send();有没有人知道为什么OxygenOS 4.1.6(7.1.1)上没有这个功能?如果可能的话,你能回答这个问题吗?我按照你的建议做了同样的事情,但是在安卓10上它对我不起作用。