Created
April 4, 2020 03:33
-
-
Save miguelhincapie/d5ab4ceefb4bad9ae3f0cf01e9d22ce1 to your computer and use it in GitHub Desktop.
Generic way to listen for any change in accessibility services state
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Observe for any accessibility service state change. Use [AccessibilityManager] to list | |
* current accessibility service ON or send [AccessibilityEvent] like a speech out. | |
*/ | |
private fun listenForAccessibilityServiceStatus(context: Context) { | |
val accessibilityManager = | |
context.getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager | |
accessibilityManager.addAccessibilityStateChangeListener { enabled -> | |
// Do your stuff | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment