Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

How to read all the coming notifications in android. Is it possible to use the broadcast receiver to listen the incoming notifications and the ability to read the notifications information.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
288 views
Welcome To Ask or Share your Answers For Others

1 Answer

First you must declare your intent to receive notifications in your manifest, so that you can get the android.permission.BIND_NOTIFICATION_LISTENER_SERVICE permission.

AndroidManifest.xml:

<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>

Then create a NotificationListenerService class and override the onNotificationPosted function.

For more information, read the developer reference here: https://developer.android.com/reference/android/service/notification/NotificationListenerService.html

Also look at this simple example application for implementation guidance: https://github.com/kpbird/NotificationListenerService-Example/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...