The Future of Android is Accessible

Aldo Socarras
11 min readMar 20, 2023

--

Image of an Android phone with an abstract background graphic

Accessibility is an essential component of modern app development that is often overlooked. We will dive into the critical role that accessibility will play in shaping the future of Android through an overview of accessibility, best practices, and how easy it is to get started as an Android engineer.

TL;DR

  • Everyone will encounter a disability in their lifetime, whether permanent (deteriorating eye-sight) or temporary (a bright or loud environment that limits your ability to use your mobile device)
  • Use the contentDescription attribute on all elements to describe their purpose with the exception of TextView (the actual text is automatically interpreted as the description)
  • Skip over decorative elements/effects that screen readers can avoid by setting the android:importantForAccessibility attribute to "no”
  • Make sure your UI’s contrast ratios are at least 4.5:1. Use https://contrast-ratio.com/ to test your colors
  • Make sure your touch targets have minimum sizing 48dp for both width and height

Personal Story

Picture of my son, Kai, at the park

This is my son, Kai.

As you can see, his character color is red. A year ago, he was diagnosed with Autism and ADHD. This diagnosis impacted our family greatly through the various challenges that we faced. Not only did we have to shift the way we perform daily tasks and the routine we maintain for the kids, but we had to navigate therapy, be on top of all the resources available to us, accommodate our son in every way possible so that he was not at a disadvantage, and help friends and family understand and accept that this diagnosis is not a viral disease. The last one was the most hurtful.

Autism and Challenges

Little Timer Hatch Countdown by Bitscuit Games

Take a look at this app. It’s a timer with an animation of an egg hatching. When the timer hits zero, it shows an image of an animal and plays a funny version of the song “Down by the Bay” made with animal noises.

This app is an absolute lifesaver because transitions are one of the hardest things to do for people on the spectrum. Whenever my son would experience an immediate change, especially when he was engaged in an activity, there would always be a struggle and a lot of reassurance required. Now we set up the timer and say, “when the egg breaks, we gotta go,” and that is the only thing that keeps him calm during the transition.

This simple application has single-handedly helped tackle one of the most challenging aspects of our lives.

People with autism often also have difficulties communicating their thoughts and feelings, which makes it hard to understand their needs and desires. This lack of understanding can lead to frustration and anger, resulting in meltdowns. Even quirks like repeating words multiple times, or not being able to control the intensity of his emotions to the point that he’s yelling out of happiness lead to a lot of people being confused out of lack of understanding and other children not wanting to play, let alone be friends, which leads to isolation and loneliness.

There is still a significant stigma attached to autism in our society. I was at a science museum one day with my family when some lady aimlessly said, “looks like this place is filled with only autistic kids because no one is listening to their parents.” It’s hurtful. Not only is it arduous to dive in, seek therapy and provide a proper home environment for them to thrive and learn, but seeing how some people view the diagnosis negatively or as an undesirable trait hurts.

An augmentative and alternative communication (AAC) device

My son was non-verbal until he was two years old. While trying to help him speak, we discovered different methods of communication: pointing, understanding cues, etc. He is three years old now. I am grateful that he has since then been verbal. But, there are a lot of other children whose situation is harder to tackle — children that have to rely on augmentative and alternative communication (AAC) devices.

In the United States, if your insurance doesn’t cover this device, you are looking at a price tag of anywhere between $200 to $7000 out of pocket. The top-of-the-line device looks like the one in the figure above. Keep in mind this is in addition to the financial burdens of therapy and the amount of time it takes to remain involved as a parent.

Why Accessibility is Important

This personal example is just a drop in the bucket. Over a billion people globally live with some form of disability, many of which face daily challenges accessing technology that most of us take for granted. That’s 1-in-7 people.

Everyone will experience some form of disability, whether permanent or temporary, but it will happen. It can be from old age, such as deteriorating eyesight or hand-eye coordination, or it can be a situational disability, such as a bright environment that limits screen visibility, loud noises in a room that limit sound reception, or something more common like distracted driver.

Technology has become increasingly integrated into every aspect of our lives, transforming how we learn, work, access healthcare, connect with others, and its impact is only continuing to grow.

Screenshot of Spotify's Car Mode enabled

Spotify did great last year in releasing Car Mode to their application. Regardless of laws, they know people will continue to drive and search for songs and play music, which can be incredibly dangerous, so they said, “well, at the very least, let’s help curve the problem, not just let it be a thing.” Now whenever you connect to your car’s Bluetooth, it turns on Car Mode, making icons larger and functions limited. You can’t pull up the song’s lyrics or type-specific song names using the keyboard, but you can access your most recently played tracks and albums, recommendations, voice control, and many more.

This feature shows how assistive technology makes for better technology for everyone, not just those with disabilities.

Getting Started

Now that we understand the importance of accessibility in our daily lives — let’s look at how easy it is for you to start making changes today and dive into some common accessibility problems and their solutions.

Screen Readers

Graphic showing Android TalkBack being used with a music app

These programs enable people with visual impairments to access digital content on a computer or mobile device. Have you ever enabled TalkBack on an Android phone? If you haven’t had to use it, I urge you to try it. It can be a jarring experience when navigating inaccessible apps.

Let’s take, for example, a company whose latest financial reports showed a revenue of $2.60 billion in 2022: Formula One Group. Formula 1 has grown exponentially in viewership over the past few years with the unlocking of the US market through the Netflix series “Drive to Survive” and other marketing efforts, doubling their revenue since then. It is the pinnacle of motorsport, where the top 20 FIA Super Licensed drivers in the world get on a grid and apply strength, endurance, agility, dexterity, reflex, and more to be milliseconds faster than their competition. Their primary app, aptly named “Formula 1”, has over 5 million downloads.

Let’s turn on TalkBack and take a closer look at this feat of engineering:

I don’t know about you, but that was repetitive. This small example shows how even widely used and popular applications can lack the fundamentals to make the app accessible and make the user’s experience frustrating. You might as well use the radio for your F1 news like in the old days.

A way to resolve this would be to use the contentDescription attribute for your UI elements to describe their purpose.

XML example of ImageView with a content description attribute

The only exception to this rule is TextView elements. We don’t need to add TextView descriptions because Android accessibility services automatically announce the actual text as the description. These are some best practices to keep in mind:

  • Avoid including the element’s type in the description. Screen readers will automatically announce both the element’s type and description.
    Remember “LoganSargeantColumn16x9.jpg image image”?
  • Each description must be unique so that the screen reader users can differentiate between different elements.
  • Skip over decorative elements/effects by setting the android:importantForAccessibility attribute to ”no” on apps with a minSdkVersion of 16 or greater

Color Contrast

An image showing the color contrast ratio of two colors

Now let’s talk color contrast and why you should stop using light grays just because they look cool. The colors you choose for your UI can affect how easy it is for users to understand it. This comparison between two colors affects people with visual impairments and those viewing an interface on devices in extreme lighting conditions, such as under direct sunlight or a display with low brightness.

A contrast ratio is our way of knowing what, regardless of color, the difference in luminance, or the intensity of light emitted, is between neighboring colors on a device’s display. This ratio usually ranges from 1:1, meaning no contrast or the same color, to 21:1, meaning high contrast.

https://contrast-ratio.com/ provides a way to test the contrast ratio between two colors, although I will be sharing some tools we can use for easier testing of your entire application’s interface.

Touch Targets

A mobile device running Player's Unknown Battleground

Lastly on the list of common problems: is touch target sizing. Have you ever downloaded a random game on your phone that contains ads with an X on the top right corner, only shown after a countdown, and then when you lock in and click on the X, it seems as if you missed the button, opening a webpage with spam? I can guarantee they didn’t follow accessibility guidelines when making that button.

The recommended touch target size is a minimum of 48dp x 48dp. For a UI element to have a large enough touch target size, the following conditions should both be true:

  • paddingLeft + minWidth + paddingRight >= 48dp
  • paddingTop + minHeight + paddingBottom >= 48dp
XML example ImageButton with a width and height of 48dp

This sizing does NOT mean the element’s visible area must be 48dp, just the interactive size of the view itself.

Testing for Accessibility

Testing for accessibility is the first step toward app accessibility and its continued improvements. One major reason for using one of the following analytic tools for testing is that many applications have elements that are not visible to the naked eye but are focusable to the screen reader, making for an irritating experience for users with visual impairments.

Manual Testing

Accessibility Scanner

Launch screen of Google's Accessibility Scanner

This application scans your screen and leverages the Accessibility Test Framework to provide specific suggestions for your app after digesting content labels, clickable items, contrast, etc. It gives you the option of a single snapshot to test or a screen recording that aggregates multiple screens and flows within your app to provide better overall suggestions.

Lucky for us, we live in a golden era where the Android Accessibility Test Framework comes integrated into Android Studio. You might have already seen it in action while creating custom views. An example is seeing the “Hardcoded text” warning for Strings that are not localized.

Google Play Pre-Launch Report

Google Play offers a feature called a pre-launch report which is automatically generated when you publish an app to internal, closed, or open testing. The report will install a test Android App Bundle of your app on multiple devices that were chilling at the Google test lab and then commands them to automatically launch and crawl your app, performing actions like typing, tapping, swiping, and reporting back with the results. The app is uninstalled once the report wraps up.

UI Automator Viewer

UI Automation with expanded view hierarchy

The uiautomatorviewer the tool helps scan and analyze UI components. You can use the Automator to inspect the layout hierarchy and view the properties of different elements visible in the foreground of the device. These features can be helpful for debugging issues found using other methods for testing, such as views with no speakable text or that are incorrectly focused when intended to be skipped.

Lint

Android Studio Lint displaying missing attribute warning

As you might have noticed, Android Studio shows lint warnings for many accessibility issues, such as the “Missing contentDescription attribute on image.” These checks are constantly improved, and we should stop ignoring those pesky yellow warnings piling in our files.

Automated Testing

These tools are geared toward teams and developers that have already established accessibility standards within their codebase and are familiar with testing.

Espresso

This library is well-known and designed to make UI testing quick and easy. It allows us to interact with different elements under test in our app and assert that certain behaviors occur or that specific conditions are triggered.

Robolectric

This framework saves precious time that we usually spend building and launching our apps by providing fast and reliable unit tests that run inside the JVM of our system. It lets you do this without an emulator. Another cool thing is that Robolectric runs in a virtual sandbox, giving you the power to configure your Android environment to specific conditions for each test, and will isolate them all from each other, giving you a bit more control over the behavior.

User Testing

Lastly, the most valuable testing method will always be actual user feedback. The people using your application and providing valuable insight, whether it is production users, specialized testing services, or groups.

Key Takeaways

Even if you are not currently affected by the accessibility issues mentioned in this post, it’s important to note that being proactive in putting accessibility at the forefront can be incredibly impactful. Here are the main takeaways on why we should aim toward building accessible Android applications as developers:

  1. User-friendly design: Many accessibility features, such as larger text sizes and high-contrast options, make it easier for all users to navigate and use their Android devices. This means that even users without disabilities can benefit from these features and have a better user experience overall.
  2. Inclusivity and social responsibility: Inclusivity is a crucial aspect of social responsibility, and making products and services accessible to all users, regardless of ability, is an important step toward creating a more inclusive and equitable society. By supporting accessibility in Android, individuals without disabilities can contribute to a more inclusive and diverse community.
  3. Future-proofing: Disability can happen to anyone at any time, and accessibility features can help people adjust to changes in their abilities. By supporting accessibility in Android, individuals without disabilities are future-proofing their devices and ensuring that they will be able to use them if they experience a change in their abilities.

--

--

Aldo Socarras

Android Engineer with a passion accessibility, teaching and bridging the gap between theory and practice 🚀 https://driuft.com/