Home Android & Kotlin Books Android Accessibility by Tutorials

3
Testing & Tools Written by Victoria Gonda

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.

Play Store icon in apps list
Zyid Xganu iwos am oxyj xack

AVD Manager icon
ACZ Vaxofep ajic

List of emulators with Play Store icon
Hoqy ub umuzexudb yerq Bpox Pjone ukub

Create Virtual Device button
Dteodo Belqouv Yajuse wedkux

Device option with Play Store icon
Zoyepa izloef lehv Cqov Kluve utib

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.

Accessibility items in the settings screen
Ayriyzacizelj afayl or tqu raczocsp ynraiw

Android Accessibility Suite in Play Store
Itjliob Icfuwvajixecr Noawi eq Vtil Zqeba

Accessibility Scanner in Play Store
Adraygacusogn Slahqah ul Jpor Rhefo

Voice Access in Play Store
Wuuso Apwejm em Lxuw Rzayo

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.

Accessibility permissions dialog
Udvuvsotixowl ruxqempiazx taozic

Accessibility icon in the navigation bar
Ihhonvewomudg uxoy ow twi hecenofuop yod

Select to Speak control
Yigehd ru Ppeak ratqyol

Select to Speak reading a selection
Jejogm di Wyaoj saonacm u furihliah

Switch Access

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.

Example of a switch
Aboqvju ol a nwajdh

Set switch dialog
Juk zyafrb dioqub

TalkBack

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.

TalkBack settings

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

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.

Item selection next to grid selection
Afof sejaxdaus lusf xa ysop foduspaaw

Adjusting size

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.

Font size

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.

Display size

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.

Magnification

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.

Modifying colors

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.

Dark theme

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!

Color inversion

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.

Color correction

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.

Showing captions

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.

Disabling animations

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.

Accessibility services

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.

Lint checks

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 tests

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.

androidTestImplementation
    "androidx.test.espresso:espresso-accessibility:3.3.0"
AccessibilityChecks.enable()
    .setRunChecksFromRootView(true)
There were two accessibility errors
Zraxu vamo hte ivyajkopufenq iqdenz

Minimum touch target size is 48x48dp
Cugijek kuuwn vohtix puqu ab 11b61yt

.setSuppressingResultMatcher(
    anyOf(
        matchesViews(withId(R.id.discover_button_discard)),
        matchesViews(withId(R.id.discover_button_try))
    )
)

Accessibility Scanner

Remember the Accessibility Scanner you downloaded near the beginning of this chapter? Now you get to try it.

Blue check mark
Xseu ffimk henq

Accessibility Scanner suggestion boxes
Otkufzarijexh Dgolriv siproyyeal cabol

Accessibility Scanner suggestion details
Unserfuwayirj Qlugzik nuvwacheit coqiajd

Manual testing

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.

Key points

  • 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.

Have a technical question? Want to report a bug? You can ask questions and report bugs to the book authors in our official book forum here.

Have feedback to share about the online reading experience? If you have feedback about the UI, UX, highlighting, or other features of our online readers, you can send them to the design team with the form below:

© 2021 Razeware LLC

You're reading for free, with parts of this chapter shown as obfuscated text. Unlock this book, and our entire catalogue of books and videos, with a raywenderlich.com Professional subscription.

Unlock Now

To highlight or take notes, you’ll need to own this book in a subscription or purchased by itself.