问题描述
如何读取Android的所有未来通知。是有可能使用广播接收机收听未来通知和读取O读的通知的信息的能力
How to read all the coming notifications in android. Is it possible to use the broadcast receiver to listen the coming notifications and the ability to read o read the notifications information
推荐答案
首先,你必须声明你的意图收到您的通知清单,这样你可以得到 android.permission.BIND_NOTIFICATION_LISTENER_SERVICE
的权限。
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中:
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>
然后创建一个 NotificationListenerService
类和重写 onNotificationPosted
功能。
有关详细信息,在这里阅读开发者参考:https://developer.android.com/reference/android/service/notification/NotificationListenerService.html
For more information, read the developer reference here: https://developer.android.com/reference/android/service/notification/NotificationListenerService.html
另外,也要看看实施的指南这个简单的示例应用程序:https://github.com/kpbird/NotificationListenerService-Example/
Also look at this simple example application for implementation guidance: https://github.com/kpbird/NotificationListenerService-Example/
这篇关于如何读取Android的所有到来的通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!