Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top