TalkBack

TalkBack is an Android screen reader made by Google. It speaks out the contents of a screen based on what the user is doing.

TalkBack works because it is an accessibility service, which is a special component that can read information from the screen (no matter which app you are using). Anyone can write their own accessibility service, but TalkBack is the most popular.

To use TalkBack, install the Android Accessibility Suite through the Google Play Store on your device (Figure 19.1).

Figure 19.1  Android Accessibility Suite

Android Accessibility Suite

Next, make sure the device’s sound output is not muted – but you may want to grab headphones, because once TalkBack is enabled the device will do a lot of “talking.”

To enable TalkBack, launch Settings and press Accessibility. Press TalkBack under the Screen readers heading. Then press the Use TalkBack (or Use service) switch to turn TalkBack on (Figure 19.2).

Figure 19.2  TalkBack settings screen

TalkBack settings screen

If this is your first time using TalkBack on the device, you will be presented with a tutorial. Go through the tutorial to learn the basic ways to navigate the system. Once the tutorial is done, TalkBack may request additional permissions. Press Allow.

Figure 19.3  Walking through the TalkBack tutorial

Walking through the TalkBack tutorial

You will notice something different right away. A green outline appears around the Up button (Figure 19.4) and the device speaks: “Navigate Up button. Double-tap to activate.”

Figure 19.4  TalkBack enabled

TalkBack enabled

(Although “press” is the usual terminology for Android devices, TalkBack uses “tap.” Also, TalkBack uses double-taps, which are not commonly used in Android.)

The green outline indicates which UI element has accessibility focus. Only one UI element can have accessibility focus at a time. When a UI element receives focus, TalkBack will provide information about that element.

When TalkBack is enabled, a single press (or “tap”) gives an element accessibility focus. Double-tapping anywhere on the screen activates the element that has focus. So double-tapping anywhere when the Up button has focus navigates up, double-tapping when a checkbox has focus toggles its check state, and so on. (Also, if your device locks, you can unlock it by pressing the lock icon and then double-tapping anywhere on the screen.)

Explore by Touch

By turning TalkBack on, you have also enabled TalkBack’s Explore by Touch mode. This means the device will speak information about an item immediately after it is pressed. (This assumes that the item pressed specifies information TalkBack can read, which you will learn more about shortly.)

Leave the Up button selected with accessibility focus. Double-tap anywhere on the screen. The device returns you to the Accessibility menu, and TalkBack announces information about what is showing and what has accessibility focus: “Accessibility. Navigate Up button. Double-tap to activate.”

Android framework views, such as Toolbar, RecyclerView, and Button, have basic TalkBack support built in. You should use framework views as much as possible so you can leverage the accessibility work that has already been done for them. It is possible to properly respond to accessibility events for custom views, but that is beyond the scope of this book.

(In Chapter 26 through Chapter 29, you will learn about a new way to build layouts on Android called Jetpack Compose. Compose’s built-in UI elements also support TalkBack and behave very similarly to what you will see in this chapter.)

Linear navigation by swiping

Imagine what it would be like to explore an app by touch for the first time. You would not know where things are located. What if the only way to learn what was on the screen was to press all around until you landed on an element that TalkBack could read? You might end up pressing the same thing multiple times – worse, you might miss elements altogether.

Luckily, there is a way to explore the UI linearly, and in fact this is the more common way to use TalkBack: Swiping right moves accessibility focus to the next item on the screen. Swiping left moves accessibility focus to the previous item on the screen. This allows the user to walk through each item on the screen in a linear fashion, rather than trial-and-error poking around in hopes of landing on something meaningful.

Navigate around the Accessibility settings page using the swiping gestures. (If you are using the emulator, you can mimic this behavior with the keyboard’s arrow keys.)

Navigating between apps and screens with the swipe system navigation behaves differently when TalkBack is enabled. When TalkBack is not enabled, you navigate to the Home screen by swiping with one finger from the bottom of the device. With TalkBack enabled, you navigate using the same gesture, but with two fingers. Likewise for Back navigation, you need a two finger swipe from the left or right edge of the device when TalkBack is enabled. Without TalkBack, you use a single finger. You also use two fingers to scroll when TalkBack is enabled.

Now, try out TalkBack in CriminalIntent. Compile and launch the app. When you open it, accessibility focus will be given to the + action item in the app bar by default. (If it is not, press the + to give it accessibility focus.) The device reads out, “CriminalIntent. New Crime. Double-tap to activate” (Figure 19.5).

Figure 19.5  New Crime action item selected

New Crime action item selected

For framework views, such as menu items and buttons, TalkBack will read the visible text content displayed on the view by default. But the New Crime menu item is just an icon and does not have any visible text. In this case, TalkBack looks for other information in the view. You specified a title in your menu XML, and that is what TalkBack reads to the user. TalkBack will also provide details about actions the user can take on the view and sometimes information about what kind of view it is.

Now swipe left. Accessibility focus moves to the CriminalIntent title in the app bar. TalkBack announces, “CriminalIntent” (Figure 19.6).

Figure 19.6  App bar title selected

App bar title selected

Swipe right, and TalkBack reads information about the + (New Crime) menu button again. Swipe right a second time; accessibility focus moves to the first crime in the list. Swipe left, and focus moves back to the + menu button. Android does its best to move accessibility focus in an order that makes sense.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset