Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to check if a notification is visible or canceled?

I would like to update notification data, but the only way I found is to launch a new one with the same Id.

The problem is that I don't want to raise a new one if the original has beed canceled. Is there a way to tell if a notification is visible or canceled? Or a way to update a notification only if it exists?

like image 580
Asaf Pinhassi Avatar asked Sep 29 '12 17:09

Asaf Pinhassi


People also ask

How do I know if my Android notification was dismissed?

You can see your Android notification history on Android 11 through the Settings app. You first need to turn on Notification history in your phone's notification settings. You will then be able to see all the alerts you dismissed in the past 24 hours.

How can I see my whole notifications?

Scroll down and long-press the “Settings” widget, then place it on your home screen. You'll get a list of features that the Settings shortcut can access. Tap “Notification Log.” Tap the widget and scroll through your past notifications.

What is displaying notification?

A notification is a message that Android displays outside your app's UI to provide the user with reminders, communication from other people, or other timely information from your app. Users can tap the notification to open your app or take an action directly from the notification.


1 Answers

If you're app has a minimum API >= 23 can use this method to get active notification:

NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); StatusBarNotification[] notifications = mNotificationManager.getActiveNotifications(); for (StatusBarNotification notification : notifications) {   if (notification.getId() == 100) {     // Do something.   } } 
like image 191
Sayed Abolfazl Fatemi Avatar answered Sep 21 '22 11:09

Sayed Abolfazl Fatemi