Reputation: 1667
Is there a way I can check programatically whether my app's notification is currently running(shown)?
That is to say that NotificationManager.notify()
was invoked.
Upvotes: 5
Views: 12996
Reputation: 42417
You can in API 23 and above. Just call NotificationManager.getActiveNotifications()
.
Upvotes: 2
Reputation: 17181
Is there a way I can check programatically whether my app's notification is currently running(shown)?
Yes. Have a look on this: How to know when my notification is cleared via Clear button?
@octavian-damiean said:
It seems like you are looking for the deleteIntent field of the Notification class.
Upvotes: 3
Reputation: 1007534
Is there a way I can check programatically whether my app's notification is currently running(shown)?
No.
That is to say that NotificationManager.notify() was invoked.
You called notify()
. Hence, you already know if notify()
was called. You also know if your code calls cancel()
or cancelAll()
. You will also know, via the various PendingIntents
and flags, if the Notification
goes away based upon user action. Hence, you have all of the information yourself to determine if the Notification
is on-screen or not.
However, savvy developers will write their apps such that they do not care if their Notification
is on-screen or not.
Upvotes: 3