Adh*_*ham 33 notifications android broadcastreceiver
如何在android中阅读所有即将发布的通知.是否可以使用广播接收器来收听传入的通知和读取通知信息的能力.
Mon*_*ban 25
首先,您必须声明在清单中接收通知的意图,以便获得android.permission.BIND_NOTIFICATION_LISTENER_SERVICE许可.
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>
Run Code Online (Sandbox Code Playgroud)
然后创建一个NotificationListenerService类并覆盖该onNotificationPosted函数.
有关更多信息,请阅读此处的开发人员参考:https://developer.android.com/reference/android/service/notification/NotificationListenerService.html
另请参阅这个简单的示例应用程序以获取实现指南:https://github.com/kpbird/NotificationListenerService-Example/