How to read notifications for API Level < 18 (NotificationListenerService requires API >= 18)

StackOverflow https://stackoverflow.com/questions/23466851

  •  15-07-2023
  •  | 
  •  

문제

I am trying read all incoming notifications (here is the code example). When I extend NotificationListenerService, I get the following message:

Call requires API level 18 (current min is 9): new android.service.notification.NotificationListenerService

I want to add this functionality to my app but do not want to alienate users who are below API level 18. Is there a workaround to this problem?

도움이 되었습니까?

해결책

Yes you can do this by using AccessibilityService. Where an accessibility service runs in the background and receives callbacks by the system when AccessibilityEvents are fired. Such events denote some state transition in the user interface, for example, the focus has changed, a button has been clicked, etc. Such a service can optionally request the capability for querying the content of the active window.

Read my bolog post Capture Toast or Notification using Accessibility Service for code example.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top