无法获取NotificationListenerService类工作工作、NotificationListenerService

2023-09-06 03:38:17 作者:女乃 口嘴

我有一个Android应用程序正试图使用​​一个继承自这个类的API 18.我已经创建了自己的服务类新NotificationListenerService类,并覆盖了onNotificationPosted和onNotificationRemoved事件,虽然我的服务似乎开始就好了这些2事件似乎从来没有被调用时,我得到或删除通知。

I have a android application that is trying to use the new NotificationListenerService class from api 18. I have created my own service class that inherits from this class and overrode the onNotificationPosted and onNotificationRemoved events and although my service seems to start just fine these 2 events never seem to be called when I get or remove a notification.

有没有人有这个类或可能任何源$ C ​​$ C任何成功他们将分享演示究竟是如何使用这个类?

Has anyone had any success with this class or possibly any source code they are will to share demonstrating exactly how to use this class?

推荐答案

我刚刚翻过这一类行动的一个伟大的小例子:

I have just come accross a great little example of this class in action:

http://www.kpbird.com/2013/07/android- notificationlistenerservice.html

有一件事情我从下面这个例子学到的是,该通知服务,我创建启动时自动许可通过新的通知访问屏幕理所当然的,这意味着我的应用程序并不需要手动启动该服务。

One thing I learned from following this example is that the notification service I created starts automatically when permission is granted via the new notification access screen, meaning my application doesn't have to start the service manually.