How to find notification ID?

Viewed 949

How can I get the title or the notification ID that I want to Clear. My App produces several notification .

Api is 19 .

using  NotificationListenerService useful?

1 Answers

Yes, you can use getActiveNotifications from NotificationListenerService to get all active notifications.

StatusBarNotification[] activeNotifications = service.getActiveNotifications();

Then loop through available notifications and use getId()

if(activeNotifications!=null){

  for(StatusBarNotification notification : activeNotifications ){

    if (notification.getId() == ID_TO_CHECK) {
       // do your operation
         }

   }
}
Related