如何在Android中获取所有活动通知?

时间:2016-07-21 07:59:00

标签: android notifications

问题似乎很熟悉,是的,我已经四处寻找解决方案,但答案不适合我的用例 我想在发布新通知之前访问所有活动通知并使用这些信息。我知道我们可以使用NotificationListenerService(https://developer.android.com/reference/android/service/notification/NotificationListenerService.html#getActiveNotifications())来获取AllActiveNotifications 但这可以帮助我在接收方收到通知发布回叫后收到通知。我基本上想在发布新通知之前检查所有活动通知,以便我不再发布具有相同内容的通知 为了发布我正在使用NotificationManageras如下:
NotificationManager nm = mContext.getSystemService(mContext.NOTIFICATION_SERVICE); nm.notify(tag, id, notification);
我不想将通知ID存储在数据库中,并在发布任何新通知时使用它。
感谢您的帮助!

更新
似乎API23可以实现这一点:
https://developer.android.com/reference/android/app/NotificationManager.html#getActiveNotifications()
但我想知道是否有任何方法可以在21或以下达到这个目的。

0 个答案:

没有答案