安卓:获得了code中所有的通知 [英] Android: get all the notifications by code
问题描述
我使用了一些家庭更换,让我隐藏通知栏和这件事情我真的很喜欢。
I am using some home replacement that allow me to hide the notification Bar and that's something I really like.
所有的信息可以通过一些小部件进行更换,但我想,以显示通知了。
All the informations can be replaced by some widgets, but I would like to display the notifications too.
正如我已经开发了一些应用程序,我想知道是否有一个命令行,允许应用程序获得所有通知。我打算把它添加到Widget或祝酒。
As I already developed some applications, I would like to know if there is a command line that allow an application to get all the notifications. I plan to add this to a widget or a toast.
感谢很多的任何线索或帮助。
Thank a lot for any clue or help.
推荐答案
由于Android的API等级18(安卓4.3),还有一类 NotificationListenerService 。 您必须设置权限的 BIND_NOTIFICATION_LISTENER_SERVICE 并使用一个意图过滤器与动作的 NotificationListenerService
Since Android API Level 18 (Android 4.3) there is a class NotificationListenerService. You must set the Permission BIND_NOTIFICATION_LISTENER_SERVICE and use a intent-filter with the action NotificationListenerService.
<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>
来源:<一href="http://developer.android.com/reference/android/service/notification/NotificationListenerService.html#getActiveNotifications%28%29">http://developer.android.com/reference/android/service/notification/NotificationListenerService.html#getActiveNotifications()
这篇关于安卓:获得了code中所有的通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!