简体   繁体   中英

how to check if notification is active in android

I get some data Jsonarray from server every 60 seconds and I use jsonarray to build notification in for-loop; However I don't know how to know if notification is active than pass next one to build the notification is there any way to do it ?

NotificationManager can keep track of it for you.

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()).

https://developer.android.com/reference/android/app/NotificationManager.html#getActiveNotifications()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM