我正在尝试读取所有传入通知(这里是 code example )。当我扩展NotificationListenerService时,我收到以下消息:
调用需要 API 级别 18(当前最低级别为 9):新的 android.service.notification.NotificationListenerService
我想将此功能添加到我的应用中,但不想疏远 API 级别 18 以下的用户。此问题有解决方法吗?
最佳答案
是的,您可以使用 AccessibilityService 来做到这一点。当 AccessibilityEvents 被触发时,辅助服务在后台运行并接收系统的回调。此类事件表示用户界面中的某些状态转换,例如焦点已更改、按钮已单击等。此类服务可以选择请求查询 Activity 窗口内容的能力。
阅读我的博文Capture Toast or Notification using Accessibility Service代码示例。
关于android - 如何读取 API 级别 < 18 的通知(NotificationListenerService 需要 API >= 18),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23466851/