Accessibility services are among the many tools Android provides for users. Some people depend on these services to view and navigate apps. Learning how to use these tools for yourself will help you get a clear picture of how your app interacts with these services. It will also help you develop empathy for your users who rely on these services.
There are also tools that automatically detect accessibility issues in your app. They include standalone scanners, as well as tools that integrate into your automated testing and IDE.
In this chapter, you’ll learn about these tools and testing for accessibility so that, as you work through the remaining chapters, you’ll be able to verify the improvements you’re making.
To get started, you need to make sure you have these tools set up on your device.
Setting up your device
You’ll need these three tools installed on your device or emulator:
- Accessibility Suite
- Accessibility Scanner
- Voice Access
Most modern physical devices come with some of the services found in the accessibility suite. Depending on your device, you may have some services but not others. If you don’t see a certain service, set up an emulator that has that service and carry on.
Prepping your emulator (optional)
Note: Many of these tools work better on a physical device than an emulator, so use that option if you have it. If you’re using a physical device, you can skip ahead to Downloading tools.
The first thing to download is the Android Accessibility Suite, a set of tools that people with disabilities use to navigate their devices.
Using accessibility services
You already know there are many accessibility settings — too many to cover in this chapter. You’ll learn about the ones that are most likely to affect the way you build your app.
Select to Speak
The first service you’ll try is Select to Speak. Go to Settings ▸ Accessibility ▸ Select to Speak and toggle the Select to Speak shortcut switch to on.
While Select to Speak allows you to read items on the screen, Switch Access enables you to navigate. It’s helpful for users who have limited mobility.
TalkBack combines reading and navigating into one service. With TalkBack, you can use gestures or a keyboard to navigate the screen, and the device reads the contents out loud. This tool is great for users with low or no vision.
Other TalkBack gestures
You can do more than next, previous, and select with TalkBack gestures.
There are more settings available. If you have developer options turned on, you can set it so that the content that’s read is also printed onscreen. To turn on developer settings, go to Settings ▸ System ▸ About device and tap the build number seven times.
Navigating using a keyboard (optional)
If you’re using an emulator or have a keyboard attached to your device, you can navigate with a keyboard.
Voice Access is a hands-free way to control a device. By saying commands like “Type Hello World”, “Back” and “Submit”, a user can type in an edit field, close the keyboard and submit a form.
When you live with vision limitations or your device is far away, adjusting the size of what’s onscreen can do wonders. Android has three ways to do this.
You can scale the font size across apps. Go to Font size in Accessibility Settings. Use the slider at the bottom of the screen to scale the text to Largest. Use a few of your favorite apps to see how they look. Text that used to fit on one line might now be on two lines or be truncated.
Changing the display size is much like scaling the text. The difference is that it also changes the size of non-text elements, such as icons. Go to Display size in Accessibility Settings to try it.
Unlike scaling, which has a universal effect, magnification allows you to zoom in on any screen. Go to Magnification in Accessibility Settings. If you have the option, go to Magnify with triple-tap. Turn the service on.
Changing colors can provide a better experience for users with vision disabilities. People may also use these options because of their preferences. Try out each of them, one at a time, turning off one before you move to the other.
Did you know that the dark theme is also an accessibility feature? Since Android 10, you can activate dark mode from Settings ▸ Display ▸ Dark Theme but you can also set it in Settings ▸ Accessibility ▸ Dark Theme on some devices. Surely, you already know which setting you prefer!
Somewhat related to the dark theme is Color inversion. As the name suggests, this takes all the colors on the screen and inverts them. Unlike the dark theme, it also inverts photos. Try turning on Color inversion on the Accessibility Settings screen.
High contrast text
High contrast text is an experimental feature at the time of this writing. Go to Settings ▸ Accessibility, then toggle on High contrast text to see how it makes the text more distinct on the screen.
The color correction setting can help with color blindness. Turn on Color correction in Accessibility Settings. Try the different types of color correction to see how it changes the colors on your screen.
Simulating color space
Rather than being an aid for users with disabilities, this tool is for developers to simulate color-blindness. Go to Settings ▸ System ▸ Advanced ▸ Developer options and scroll (way) down to Simulate color space. Try the different options in multiple apps.
Newer devices come with Live Caption. This feature detects when the device plays audio with speech and captions it. Like the other services, you enable this in Accessibility Settings. Look for Live Caption, turn it on then play a podcast or other audio with speech in it.
Although some users love animations, for others, they can be distracting or even nauseating. That’s why there’s an option to turn them off. Go to Settings ▸ Accessibility ▸ Remove animations and toggle the switch on. The change is typically subtle. Notice that when you switch apps, you no longer see the animated transitions.
Many of these tools hook into the same accessibility services. These services communicate with app views to understand the content and what actions are possible. They know the bounds of each view and can decipher if something important changed.
Testing for accessibility
Now that you know how to use many of these accessibility services, you’ll dig into the best way to test your apps for accessibility. There are many tools available.
In Chapter 2, “Hello, Accessibility”, you learned how lint checks help you improve your app. Lint enables you to maximize accessibility by providing feedback from an early development stage, right in your IDE.
Espresso, one of the leading libraries used for UI tests on Android, also includes accessibility checks. You don’t even need to write additional tests to use it! It runs alongside your existing Espresso tests.
.setSuppressingResultMatcher( anyOf( matchesViews(withId(R.id.discover_button_discard)), matchesViews(withId(R.id.discover_button_try)) ) )
Remember the Accessibility Scanner you downloaded near the beginning of this chapter? Now you get to try it.
You’ve already been manually testing in this chapter, and it’s one of the most reliable ways to test your app. Use the tools you learned above, such as TalkBack, to see how your app behaves. Is something hard to see or do with one of these tools? If so, you know there’s a potential issue.
Knowing how much to test
So many tools. Are you feeling overwhelmed? It’s okay to start small. Running these scanners on an existing multi-screen app can be a chore. Don’t run boldly into a testing scenario without developing a strategy first. You need a strategy to define the desired level of conformity and what you need to do to achieve it. Then figure out how much you can spend on time, money and resources. This strategy will look different for each team.
- Download Accessibility Suite and Accessibility Scanner from the Play Store.
- Select to Speak, Switch Access, TalkBack and Voice Access are all ways of viewing and navigating your device.
- Users can change the size of views with magnification and adjust the font size and display size.
- Color settings can change to suit the user’s preferences.
- Captions can make audio accessible for those with hearing impairments.
- Animations can be disabled for users who find them to be unhelpful or distracting. Use lint checks, Espresso tests, Accessibility Scanner and manual testing to measure your app’s accessibility.
- Using the accessibility tools for yourself is the ultimate way to understand your app’s accessibility.
- Strategy is critical to successfully implementing accessibility support in your app.