How to catch Accessibility events only when the app is in foreground and not from the notifications?

567 views Asked by At

I have an AccessibilityService that listens to events from a specific package XYZ. I want to be notified only when an app is actually launched (or running in the foreground). But when my service is registered to listen to TYPE_WINDOW_CONTENT_CHANGED event, it also listens to events when there is a new notification from the package XYZ. How do I distinguish if the event is from a notification or from the app running in the foreground?

1

There are 1 answers

0
Sakethram On BEST ANSWER

Listening to TYPE_WINDOW_STATE_CHANGED event did the job for me.