Search code examples
androidandroid-serviceaccessibility-api

Using Accessibility Service Android


I have made use of Accessibility service in android to detect the foreground application.

I want to listen to 2 of the available accessibility events

TYPE_VIEW_TEXT_CHANGED

TYPE_WINDOW_STATE_CHANGED

I want to listen to all window state change events, that is working, but for second event, i want to listen to view_text_changed event of only 1-2 applications and not all.

I have read & tried the android:packageNames parameter in xml, but then it will impose limitation on window_state_changed event.

Is there any other way to do that??


Solution

  • Unfortunately there isn't way to specify interesting package names for specified accessibility events. You have to just use AccessibilityEvent#getPackageName to filter interesting you packages.