I'm working on an Android mobile application and need to know if TalkBack is active on startup and detect TalkBack off/on state changes while application is running.
Previously the code used JavaScript accessibility component and called C++ and then Java. Now we only want Java code.
How can I implement this functionality?
I was able to get the Talkback active/inactive status notification using AccessibilityManager.addTouchExplorationStateChangeListener. This resolved the issue I had with Android mobile.
try {
am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
am.addTouchExplorationStateChangeListener(new AccessibilityManager.TouchExplorationStateChangeListener () {
@Override
public void onTouchExplorationStateChanged(boolean enabled) {
onTalkbackStatusChanged(enabled);
}
});
} catch(Exception ex) {
...
}