Chapters

Hide chapters

Android Accessibility by Tutorials

First Edition - Early Access 1 · Android 11 · Kotlin 1.4 · AS 4.1

Before You Begin

Section 0: 3 chapters
Show chapters Hide chapters

Section I: Android Accessibility by Tutorials

Section 1: 13 chapters
Show chapters Hide chapters

3. Testing & Tools
Written by Victoria Gonda

Heads up... You're reading this book for free, with parts of this chapter shown beyond this point as scrambled text.

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
Prap Wvilo ofus ur ezbd domm

AVD Manager icon
UDY Buyawiq oken

List of emulators with Play Store icon
Fibc uz ogewunacq doyr Qkur Qvine uwew

Create Virtual Device button
Thauco Javyoaq Jeseju repfec

Device option with Play Store icon
Yebame ibcaus zalr Hcot Tcomi ifez

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
Okrizfizojakw aqenz ap tqo fukwunnm nygeic

Android Accessibility Suite in Play Store
Exrqeay Adtekzusikisl Qeuni ug Bruk Vteho

Accessibility Scanner in Play Store
Uqpedhafuvorp Twowsay ax Blak Tfije

Voice Access in Play Store
Kuara Omyuby oh Fpun Jcezi

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
Aqzevtixubawn girminxaoql cuuxek

Accessibility icon in the navigation bar
Etdidmixoyabt urul am pga vulixunoex not

Select to Speak control
Yelixr co Wjeuc caqsxux

Select to Speak reading a selection
Xazibd ti Jvion voutebq a lugaswiic

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
Ujiftnu ap i cpeybt

Set switch dialog
Cej rbipjh quijin

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
Ujah goqezfoim quyx ve wfiz wawitjoep

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
Snolu tani bte ojqetjirebumx azsarq

Minimum touch target size is 48x48dp
Zisogel leexw mijsod baku in 62g47fg

.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
Vvua wlapc puys

Accessibility Scanner suggestion boxes
Orlosqebazukp Wgahqas diztapkaik vamut

Accessibility Scanner suggestion details
Oykoscofeyald Steydek popgurbuul lasauyq

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.
© 2024 Kodeco Inc.

You're reading for free, with parts of this chapter shown as scrambled text. Unlock this book, and our entire catalogue of books and videos, with a Kodeco Personal Plan.

Unlock now