androidnotificationsaccessibilityservicenotification-listener

NotificationListener Or Accessibility Service


I want to read the incoming notification from the notification bar. I have read that this can be done using both Accessibility Service and Notification Listener. Which one is the better one to use and Why?

Thanks


Solution

  • It depends on WHY you want to read it. The general answer would be Notification Listener. Accessibility Services are for unique accessibility services. A user has to enable an accessibility service from within the Accessibility Service menu (where TalkBack and Switch Access are). Their ability to read notifications is a secondary ability, to help them achieve the goal of creating assistive technologies (alternative ways for people to interact with mobile devices).

    Whereas, Notification Listeners, this is their primary goal. They exist as part of the context of an app and as such don't need to be specifically turned on from the accessibility menu.

    Basically, unless you are in fact building an accessibility service, you should not use this approach, and go with the generic Notification Listener.