【问题标题】:How to read notifications for API Level < 18 (NotificationListenerService requires API >= 18)如何读取 API 级别 < 18 的通知(NotificationListenerService 需要 API >= 18)
【发布时间】:2014-05-05 15:19:52
【问题描述】:

我正在尝试阅读所有传入的通知(这里是code example)。当我扩展 NotificationListenerService 时,我收到以下消息:

调用需要 API 级别 18(当前最低为 9):新的 android.service.notification.NotificationListenerService

我想将此功能添加到我的应用中,但不想疏远低于 API 级别 18 的用户。是否有解决此问题的方法?

【问题讨论】:

    标签: android service notifications


    【解决方案1】:

    是的,您可以使用AccessibilityService 来执行此操作。无障碍服务在后台运行并在触发 AccessibilityEvents 时接收系统的回调。此类事件表示用户界面中的某些状态转换,例如焦点已更改、按钮已单击等。此类服务可以选择请求查询活动窗口内容的能力。 p>

    阅读我的博文Capture Toast or Notification using Accessibility Service 以获取代码示例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-19
      • 1970-01-01
      相关资源
      最近更新 更多