我希望从设置中保持通知打开,并且希望在收到Whatsapp通知两分钟后自动消除。我在网上搜索了一下如何移除通知:点这里。其中介绍了通过ClearAll或通知ID清除通知的方法,但是我不知道如何找到ID。
NotificationManager.cancel(id)
和NotificationManager.cancelAll()
只会影响你的应用程序发布的通知。NotificationListenerService.getActiveNotifications()
然后筛选它们,找到来自你所需包的通知。 - Pawel
if(sbm.getPackageName().equals("com.whatsapp")) cancelNotification(sbm.getKey());
而不是像之前的答案中使用cancelAllNotifications。 - Bhavita Lalwani