1

I am trying to build an app that monitors the notifications using NotificationListenerService which was released from API 18. After doing a lot of research, I found out nothing about it.

To the best of my knowledge, all of the queries (related to NotificationListenerService) are related to detecting notification and reading notification details. I am able to do all this. But, I want to monitor if the user is clicking on the notification or ignoring it (by swiping side ways).

I am not sure if it is actually possible to do or not?

Note: I know that we can monitor when a new notification appears on the notification bar and when it is removed by using NotificationListenerService. But, I also want to know if the removed notification was clicked or ignored? Hope I am clear with my question.

abhi
  • 1,412
  • 19
  • 25
  • You can find one possible solution at this link: [how-to-know-if-user-clicked-on-the-notification](http://stackoverflow.com/questions/33088355/android-notificationlistenerservice-how-to-know-if-user-clicked-on-the-notifica/34623515#34623515) – t.montanaro Jan 06 '16 at 00:13

1 Answers1

-1

For removing notification a method called onRemovedNotification():

@Override
public void onNotificationRemoved(StatusBarNotification sbn) {
    sbn.getId();
    super.onNotificationRemoved(sbn);

}

and for current notification:

@Override
public void onNotificationPosted(StatusBarNotification sbn) {


    super.onNotificationPosted(sbn);
}

so other notification other than that can be determined as read.... Hope this helps :)

kiturk3
  • 549
  • 10
  • 30
  • My qeustions is- how to detect if the removed notification was clicked (to read) or ignored (by swiping side way)? – abhi Dec 26 '14 at 10:40
  • your solution is to find which notification has been removed.. but, I want to detect more than that. Btw, what do you mean by- we cant detect id 2, but we can detect 1 and 3 by having redirection of intent for respective app. – abhi Dec 26 '14 at 11:17
  • i am saying that we can detect id 2 by onNotificationRemoved(StatusBarNotification sbn) – kiturk3 Dec 27 '14 at 06:24
  • That's not my question. Instead I want to know if the removed notification was clicked or cancelled? – abhi Dec 27 '14 at 10:41
  • if notification is removed than it can be found in onNotificationRemoved(StatusBarNotification sbn) class. orelse you can give intentfilter while redirecting through notification – kiturk3 Dec 27 '14 at 10:44
  • What can i do with intent filter? – abhi Dec 27 '14 at 10:53