Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
NotificationListenerService Example
Java Shell Groovy
branch: master
Failed to load latest commit information.
NLSExample Update Example
gradle/wrapper Initial Commit
NLSExampleProject.iml Initial Commit Initial Commit
build.gradle Initial Commit
gradlew Initial Commit
gradlew.bat Initial Commit Initial Commit
settings.gradle Initial Commit



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


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

Mou icon Mou icon Mou icon Mou icon

Something went wrong with that request. Please try again.