How to check which notifications are active in status bar in Android Dev?
android
Solution
I want to be able TO CHECK (in the code) IF THE NOTIFICATION IS VISIBLE TO THE USER. (i.e. can the user see the notification in the status bar?).
How can I do this?
You can't, sorry. Update: Now possible with Android 4.3+ http://developer.android.com/reference/android/service/notification/NotificationListenerService.html#getActiveNotifications()
However, you can always simply `cancel()` it -- canceling a `Notification` that is not on-screen is perfectly fine. Conversely, you can always safely call `notify()` again for the same `Notification`, and it too will not cause a problem if the `Notification` is already on-screen.
EDIT:
NotificationManager.getActiveNotifications() was added in API 23 if you don't want to use the `NotificationListenerService`
Problem
I have made an app that sets notifications in the drop-down status bar of Android phones. However, there is a bug in my code (sometimes the notifications are set, sometimes they are not). I want to be able TO CHECK (in the code) IF THE NOTIFICATION IS VISIBLE TO THE USER. (i.e. can the user see the notification in the status bar?). How can I do this? (Thanks in advance). Sample code is greatly appreciated.