Background
- I have previously researched Android accessibility, and I feel that there are still many things that are not well known, so I would like to provide as much information as possible.
- Google’s Android app accessibility guidelines can be found here. https://developer.android.com/guide/topics/ui/accessibility/apps.html
Android Accessibilty Features
- You can turn on/off various functions from Settings → Accessibility.
- Includes TalkBack (voice reading function), font size specification, enlarged display, subtitles, color correction (color blindness), color inversion, etc.
- This article will focus on TalkBack and font size specification functions, which must be taken into consideration when developing applications.
What is TalkBack?
- A standard Android support tool for visually impaired users. It has a function that reads aloud the place you tap or focus on. By turning it on, the touch operation system will also change, with a single tap to focus, a double tap to confirm, and screen scrolling using two fingers.
What apps should be aware of when Turning on TalkBack
Set contentDescription
- If the contentDescription of the View component is not set, items that do not have text information such as Images will not be read out.
- EditText can be read out by setting the hint attribute.
- TextView reads out the set Text without setting contentDescription.
- SurfaceView does not read out, so you have to read it out yourself. This is mainly necessary for game apps, etc., and it is necessary to think about what to do to achieve accessibility from the beginning.
- There are some parts of WebView that are read aloud and some parts that are not read out, so check them.
- Missing contentDescription attribute on image may appear when using Lint, a static analysis tool.
- By writing more details here than the text displayed outside of the image, it will be easier to understand when reading out
- Please write the minimum necessary explanation in contentDescription. If it is too long, users may give up listening.
Support Keyboard controls
- Enabling TalkBack changes the system to a focus-based operation system. Therefore, it is necessary to make it possible to focus on GUI components that can be operated. Also, it is necessary to make sure that labels that cannot be manipulated are focused and read out.
- Specifically, set the focusable attribute to true.
Raise an AccessibilityEvent
- You can generate an AccessibilityEvent to read out at any time. sample code is here.
public void sendAccessibilityEvent(String text, View source) {
AccessibilityManager manager = (AccessibilityManager) getSystemService(Context.ACCESSIBILITY_SERVICE);
if(manager.isEnabled()){
AccessibilityEvent event = AccessibilityEvent.obtain();
event.setEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT);
event.setClassName(getClass().getName());
event.getText().add(text);
event.setSource(source);
manager.sendAccessibilityEvent(event);
}
}
Check TalkBack ON/OFF and turn off ads
- Advertisements can be extremely troublesome for people who are blind or have difficulty seeing, as if they touch them by mistake, they may not be able to return or be directed to dangerous sites. Naturally, if you hide it, people won’t click on it, but we think accessibility should be a priority.
- You can check ON/OFF of TalkBack by using AccessibilityManager’s isEnabled() and isExploreByTouchEnabled().
AccessibilityManager am = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE);
boolean isAccessibilityEnabled = am.isEnabled();
boolean isExploreByTouchEnabled = am.isTouchExplorationEnabled();
https://stackoverflow.com/questions/5116867/how-to-know-if-android-talkback-is-active