kkudi
kkudi

Reputation: 1667

Check if my application's notification is running

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

Answers (3)

Sam
Sam

Reputation: 42417

You can in API 23 and above. Just call NotificationManager.getActiveNotifications().

Upvotes: 2

Felipe
Felipe

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

CommonsWare
CommonsWare

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

Related Questions