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