java.lang.Object | ||||
↳ | android.content.Context | |||
↳ | android.content.ContextWrapper | |||
↳ | android.app.Service | |||
↳ | android.service.notification.NotificationListenerService |
A service that receives calls from the system when new notifications are posted or removed.
To extend this class, you must declare the service in your manifest file with
the
BIND_NOTIFICATION_LISTENER_SERVICE
permission
and include an intent filter with the
SERVICE_INTERFACE
action. For example:
<service android:name=".NotificationListener" android:label="@string/service_name" android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"> <intent-filter> <action android:name="android.service.notification.NotificationListenerService" /> </intent-filter> </service>
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | SERVICE_INTERFACE |
The
Intent
that must be declared as handled by the service.
|
[Expand]
Inherited Constants
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.app.Service
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From class
android.content.Context
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From interface
android.content.ComponentCallbacks2
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Inform the notification manager about dismissal of all notifications.
|
||||||||||
|
Inform the notification manager about dismissal of a single notification.
|
||||||||||
|
Request the list of outstanding notifications (that is, those that are visible to the
current user).
|
||||||||||
|
Return the communication channel to the service.
|
||||||||||
|
Implement this method to learn about new notifications as they are posted by apps.
|
||||||||||
|
Implement this method to learn when notifications are removed.
|
[Expand]
Inherited Methods
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.app.Service
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From class
android.content.ContextWrapper
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From class
android.content.Context
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From class
java.lang.Object
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From interface
android.content.ComponentCallbacks
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From interface
android.content.ComponentCallbacks2
|
The
Intent
that must be declared as handled by the service.
Inform the notification manager about dismissal of all notifications.
Use this if your listener has a user interface that allows the user to dismiss all
notifications, similar to the behavior of Android's status bar and notification panel.
It should be called after the user invokes the "dismiss all" function of your UI;
upon being informed, the notification manager will actually remove all active notifications
and you will get multiple
onNotificationRemoved(StatusBarNotification)
callbacks.
Inform the notification manager about dismissal of a single notification.
Use this if your listener has a user interface that allows the user to dismiss individual
notifications, similar to the behavior of Android's status bar and notification panel.
It should be called after the user dismisses a single notification using your UI;
upon being informed, the notification manager will actually remove the notification
and you will get an
onNotificationRemoved(StatusBarNotification)
callback.
Note:
If your listener allows the user to fire a notification's
contentIntent
by tapping/clicking/etc., you should call
this method at that time
if
the Notification in question has the
FLAG_AUTO_CANCEL
flag set.
pkg | Package of the notifying app. |
---|---|
tag |
Tag of the notification as specified by the notifying app in
notify(String, int, android.app.Notification)
.
|
id |
ID of the notification as specified by the notifying app in
notify(String, int, android.app.Notification)
.
|
Request the list of outstanding notifications (that is, those that are visible to the current user). Useful when you don't know what's already been posted.
Return the communication channel to the service. May return null if
clients can not bind to the service. The returned
IBinder
is usually for a complex interface
that has been
described using
aidl
.
Note that unlike other application components, calls on to the IBinder interface returned here may not happen on the main thread of the process . More information about the main thread can be found in Processes and Threads .
intent |
The Intent that was used to bind to this service,
as given to
Context.bindService
. Note that any extras that were included with
the Intent at that point will
not
be seen here.
|
---|
Implement this method to learn about new notifications as they are posted by apps.
sbn |
A data structure encapsulating the original
Notification
object as well as its identifying information (tag and id) and source
(package name).
|
---|
Implement this method to learn when notifications are removed.
This might occur because the user has dismissed the notification using system UI (or another notification listener) or because the app has withdrawn the notification.
NOTE: The
StatusBarNotification
object you receive will be "light"; that is, the
result from
getNotification()
may be missing some heavyweight
fields such as
contentView
and
largeIcon
. However, all other fields on
StatusBarNotification
, sufficient to match this call with a prior call to
onNotificationPosted(StatusBarNotification)
, will be intact.
sbn |
A data structure encapsulating at least the original information (tag and id)
and source (package name) used to post the
Notification
that
was just removed.
|
---|