I\'m developing an application that uses TalkBack to guide people through it. However, in those situations I want to have some subtile differences in the layout of the appli
Thanks to @david-z answer (https://stackoverflow.com/a/41357058/2713403) I made this approach to know if the Android Accessibility Suite by Google is enabled
/**
* This method checks if Google Talkback is enabled by using the [accessibilityManager]
*/
private fun isGoogleTalkbackActive(accessibilityManager : AccessibilityManager) : Boolean
{
val accessibilityServiceInfoList = accessibilityManager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_SPOKEN)
for (accessibilityServiceInfo in accessibilityServiceInfoList)
{
if ("com.google.android.marvin.talkback".equals(accessibilityServiceInfo.resolveInfo.serviceInfo.processName))
{
return true
}
}
return false
}
Remember to register the google URI as constant :) and get the Accessibility Manager instance as @caseyburkhardt says (https://stackoverflow.com/a/12362545/2713403). The difference with the @david-z answer is that I got the Android Accessibility Suite package name instead of its app name because it is more secure. If you want to review if another accessibility suite is enabled (like the Samsung Screen Reader) after this check, you can check
if (accessibilityManager.isTouchExplorationEnabled)
Cheers!
The recommended way of doing this is to query the AccessibilityManager
for the enabled state of accessibility services.
AccessibilityManager am = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE);
boolean isAccessibilityEnabled = am.isEnabled();
boolean isExploreByTouchEnabled = am.isTouchExplorationEnabled();