---
title: "Test Android app accessibility in C#"
url: https://recursiveai.org/oneapp/cookbook/test-android-app-accessibility-talkback-uiautomator/
description: "Use adb and UI Automator to inspect accessible names and roles in a running C# OneApp project, then check what TalkBack adds to the test."
version: "1.2.1"
---

Inspect the Android accessibility tree.

```shell
dotnet add package RecursiveAI.OneApp
dotnet tool install -g RecursiveAI.OneApp.Cli
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (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](https://recursiveai.org/oneapp/cookbook/run-csharp-app-on-android-emulator/#how-do-i-launch-the-android-emulator-from-the-command-line) and wait until Android finishes booting.

```shell
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](https://developer.android.com/guide/topics/ui/accessibility/testing#talkback).

[The example](https://recursiveai.org/oneapp/cookbook/test-android-app-accessibility-talkback-uiautomator/test-android-app-accessibility-talkback-uiautomator.zip) 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

```csharp
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:

```shell
adb shell cat /sdcard/ui.xml
```

## Related recipes

- [Run and test a C# app on the Android emulator](https://recursiveai.org/oneapp/cookbook/run-csharp-app-on-android-emulator/)
- [Enable AT-SPI accessibility in a C# desktop app](https://recursiveai.org/oneapp/cookbook/enable-linux-at-spi-in-desktop-app/)

## 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](https://recursiveai.org/oneapp/docs/accessibility/#ios-and-android). 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](https://developer.android.com/guide/topics/ui/accessibility/testing#talkback) 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](https://recursiveai.org/oneapp/docs/accessibility/#ios-and-android). 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](https://github.com/recursive-ai-oss/oneplatform-csharp/blob/02f1c4ca42c0483f86b1473003132a3386877ddd/build/android/OnePlatformActivity.java#L619-L627) 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.
