Recursive AI

Test Android app accessibility in C#

OneApp is a free, open-source framework for apps in .NET whose UI is HTML and CSS, drawn natively with no web view on Windows, macOS, Linux, iOS and Android, and run in the browser, from Recursive AI. MIT or Apache-2.0, no native DLLs to ship.

Inspect the Android accessibility tree.

Terminal
dotnet add package RecursiveAI.OneApp
dotnet tool install -g RecursiveAI.OneApp.Cli

Requires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.

Use a Linux x86-64 host with the Android SDK (platform, build-tools, and platform-tools) and the NDK. These steps don’t cover Windows or macOS hosts. Start one Android emulator and wait until Android finishes booting.

Terminal
oneapp run . --android
adb shell uiautomator dump /sdcard/ui.xml
adb pull /sdcard/ui.xml .

The dump doesn’t test what TalkBack says; see how to test with TalkBack.

The example is the full program below: unzip it and dotnet run.

Run the commands above in the unzipped project to launch the Android app and write ui.xml in your working directory. dotnet run opens the desktop version; the XML check needs the Android launch above. The sample uses OneApp and its CLI 1.2.1.

Full program

C#
using OneApp;
 
public static class Program
{
    public static int Main(string[] args)
    {
        using var host = AppHost.Create(new AppOptions(new MainPage())
        {
            Title = "AccessibilityCheck",
            AppId = "org.example.accessibilitycheck",
        });
        host.Run();
        return 0;
    }
}

OneApp builds the MainPage class from this MainPage.html when you build the project. The edit field has an explicit accessible name; the button gets its name from its text.

HTML
<main class="page">
  <h1>Profile</h1>
  <input id="name" aria-label="Display name" />
  <button id="save">Save profile</button>
</main>

Open ui.xml and look for the named button and the focusable edit field. These are excerpts from the Android 15 emulator dump, with unrelated attributes omitted:

Text
<node text="" class="android.widget.EditText"
      content-desc="" focusable="true" … />
<node text="Save profile" class="android.widget.Button"
      clickable="true" … />

The edit field’s content-desc is empty because on Android API 26 and later its name is exposed as hint text, which this dump doesn’t show. To check the name, focus the field with TalkBack and listen for “Display name.”

If the XML shows the launcher or a system dialog instead of your app, bring your app to the foreground, dismiss any overlays, and dump it again.

Variations

Read the XML directly to the terminal. After dumping the hierarchy, use this instead of pulling a file to your computer:

Terminal
adb shell cat /sdcard/ui.xml

The short answer

Use adb shell uiautomator dump while the OneApp screen is in the foreground. Android queries the app’s accessibility node provider, which exposes the page’s controls as Android nodes. Start with a control you can recognize by name, then check its Android class and whether it exposes the expected actions. A dump checks the information Android can read, not what TalkBack says or how easy the app is to use.

How do you test mobile app accessibility on Android?

Check both the tree and the workflow. In the tree, confirm that text fields have meaningful names and buttons have an appropriate role. Test the screen state you care about: the initial screen and the screen after opening a dialog can have different trees. When a OneApp aria-modal dialog is open, the tree holds only the dialog. Check that its controls appear and repeat the dump after closing it to see the underlying page again.

Do a separate pass with a screen reader. Follow Android’s TalkBack testing instructions to enable it in Settings → Accessibility → TalkBack. Swipe through the screen in both directions and double-tap to activate the focused control. Check that the announcements make sense in order and that you can complete the task without looking at the screen. The example above was checked with UI Automator, not with TalkBack speech.

What does UI Automator show that an HTML inspection doesn’t?

It shows what Android receives from the running app, not the input tags. A OneApp <button> can appear as an Android button, and an <input> as an Android edit field. OneApp maps roles, actions, states and bounds through its Android accessibility bridge. Check class for the mapped role rather than searching for the original HTML tag. The button’s name appears in text. The edit field is different: the Android bridge exposes an editable field’s name as hint text on API 26 and later. The standard dump above doesn’t show that hint, so don’t read the empty content-desc as proof that the label is missing. A correct label in the dump still leaves open questions about spoken feedback, focus order, and whether an action works in the screen reader.

All oneapp recipes