I've run into a rather unfortunate problem with an application I'm developing that utilizes an accessibility service to do some special handling of notifications when they arrive on a user's device. The thing is, it works just fine, but the service's 'onAccessibilityEvent' function is never invoked unless the service is restarted from Android's Accessibility page, i.e. I must first enable the service from that page, then disable it, then enable it again in order for 'onAccessibilityEvent' to be called at all.
I've tried using Google's example without making any changes of my own, but even then I still appear to be experiencing the same issue, so I'm not sure what to make of what's going on here. Has anyone run into this problem?
This is because the Service is being killed by the Android framework which requires restarting it from the accessibility menu.
Youcan validate this by adding logs in onDestroy() method
This happens probably for a android bug as it is solved in newer android version. when you power off
onUnbind
is called. Buton_boot_finished
onRebind
is not called, so your service remains useless. I have provided my solution to this problem here, please check this out.