Android:通过代码获取所有通知 [英] Android: get all the notifications by code

查看:65
本文介绍了Android:通过代码获取所有通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一些家庭替代品,它允许我隐藏通知栏,这是我真正喜欢的东西.

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.

因为我已经开发了一些应用程序,我想知道是否有一个命令行允许应用程序获取所有通知.我打算将其添加到小部件或祝酒词中.

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 Level 18 (Android 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>

来源:http://developer.android.com/reference/android/service/notification/NotificationListenerService.html#getActiveNotifications()

这篇关于Android:通过代码获取所有通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆