如何检查 android 中的通知是否处于活动状态
how to check if notification is active in android
我每 60 秒从服务器获取一些数据 Jsonarray,我使用 jsonarray 在 for-loop 中构建通知;
但是我不知道如何知道通知是否处于活动状态而不是通过下一个通知来构建通知
有什么办法吗?
NotificationManager 可以为您跟踪它。
getActiveNotifications:
added in API level 23
StatusBarNotification[] getActiveNotifications ()
Recover a list of active notifications: ones that have been posted by the calling app that have not yet been dismissed by the user or cancel(String, int)ed by the app. Each notification is embedded in a StatusBarNotification object, including the original tag and id supplied to notify() (via getTag() and getId()) as well as a copy of the original Notification object (via getNotification()).
我每 60 秒从服务器获取一些数据 Jsonarray,我使用 jsonarray 在 for-loop 中构建通知; 但是我不知道如何知道通知是否处于活动状态而不是通过下一个通知来构建通知 有什么办法吗?
NotificationManager 可以为您跟踪它。
getActiveNotifications: added in API level 23 StatusBarNotification[] getActiveNotifications () Recover a list of active notifications: ones that have been posted by the calling app that have not yet been dismissed by the user or cancel(String, int)ed by the app. Each notification is embedded in a StatusBarNotification object, including the original tag and id supplied to notify() (via getTag() and getId()) as well as a copy of the original Notification object (via getNotification()).