I have question about Accessibility Service in Android.
Can I catch a notification in status bar and get info from notification?
My purpose is to catch notification of apps like Viber, Skype.
Is that possible?
I have question about Accessibility Service in Android.
Can I catch a notification in status bar and get info from notification?
My purpose is to catch notification of apps like Viber, Skype.
Is that possible?
您可以查看 NotificationListenerService。不确定它是否能满足您的需求,但根据文档:
在发布或删除新通知或更改其排名时接收来自系统的调用的服务。
您可以使用getActiveNotifications()获取活动通知。以为我从未对此进行过测试,也不知道它是在状态栏中收到其他应用程序通知还是只有您的通知。
这是该方法的当前描述:
请求未完成通知的列表(即当前用户可见的通知)。当您不知道已发布的内容时很有用。
您可以获得更多信息@NotificationListenerService
注意:此方法仅适用于 API 18。
进一步调查我发现了另一个用户关于如何使用 NotificationListenerService 的示例:
https://github.com/kpbird/NotificationListenerService-Example
AccessibilityService 用于处理可访问性触摸:
无障碍服务在后台运行,并在触发 AccessibilityEvents 时接收系统的回调。此类事件表示用户界面中的某些状态转换,例如焦点已更改、按钮已被单击等。此类服务可以选择请求查询活动窗口内容的能力。无障碍服务的开发需要扩展这个类并实现它的抽象方法。
您可以使用NotificationListenerService,它很容易使用,请看这篇博文。