NotificationListenerService Example
Java Shell Groovy
Switch branches/tags
Nothing to show
Latest commit 308cfb2 Aug 2, 2013
Failed to load latest commit information.
NLSExample Update Example Aug 2, 2013
gradle/wrapper Initial Commit Jul 31, 2013
NLSExampleProject.iml Initial Commit Jul 31, 2013 Initial Commit Jul 31, 2013
build.gradle Initial Commit Jul 31, 2013
gradlew Initial Commit Jul 31, 2013
gradlew.bat Initial Commit Jul 31, 2013 Initial Commit Jul 31, 2013
settings.gradle Initial Commit Jul 31, 2013


##Introduction NotificationListenerService is introduced in Android 4.3 (API 18). It allows an application to receive information about notifications as it creates or removes. NotificationListenerService class is derived from the Service class. It has two abstract methods namely 1. onNotificationPosted 2. onNotificationRemoved.
To use NotificationListenerService, we need to create a java file which extends NotificationListenerService and implement two callback methods. Both methods have a parameter named "sbn", which is an object of StatusBarNotification class. StatusBarNotification provides necessary information about Notifications. NotificationListenerService provides facility to fetch active notifications using getActiveNotifications and also provides a feature to remove notifications using cancelAllNotifications.

##Useful Methods

  1. NotificationListenerService
    • onNotificationPosted
    • onNotificationRemoved
  2. StatusBarNotification
    • getId
    • getNotification
    • getPackageName
    • getPostTime
    • isClearable
    • isOngoing

##Note User require to enable notification permission from "Settings > Security > Notification access".

Mou icon Mou icon Mou icon Mou icon