Ahmet ATAK
Ahmet ATAK

Reputation: 342

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 ?

Upvotes: 0

Views: 489

Answers (1)

Mercato
Mercato

Reputation: 569

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

Upvotes: 1

Related Questions