ComposeA11yScanner

Top-level public API for the Compose Accessibility Scanner.

install attaches a transparent overlay to a ComponentActivity that renders the scan summary bar, issue detail panel, and highlight boxes over flagged nodes. The overlay is removed automatically when the activity is destroyed, so explicit uninstall calls are only needed if the scanner should stop before destroy.

Scanner calls are allowed by default in debuggable builds and denied by default in non-debuggable builds. toggleScanner explicitly overrides either default: false disables the scanner in every build, while true enables it in every build. Checking ApplicationInfo.FLAG_DEBUGGABLE is correct for library code because a library module's BuildConfig.DEBUG does not reflect the consuming app's build type.

Usage:

// Activity.onCreate — after setContent { … }
ComposeA11yScanner.install(this)

// Anywhere:
lifecycleScope.launch {
ComposeA11yScanner.scan().collect { state -> /* react to ScannerState */}
}

Functions

Link copied to clipboard
fun install(activity: ComponentActivity, config: ScannerConfig = ScannerConfig(enabledRules = ScannerRules.allRuleIds().toSet()))

Attaches the accessibility scanner overlay to activity.

fun install(activity: ComponentActivity, destinationKeyProvider: () -> String?, config: ScannerConfig = ScannerConfig(enabledRules = ScannerRules.allRuleIds().toSet()))

Installs the scanner with an explicit key for single-host Compose navigation. Return the current route, pane, or other stable destination identifier from the provider.

Link copied to clipboard

Invalidates the current result and schedules a scan for the latest destination.

Link copied to clipboard
fun scan(): Flow<ScannerState>

Returns scanner state for the latest resumed automatic activity, or the latest surviving manual installation when automatic routing has no active entry.

Link copied to clipboard

Overrides the default scanner availability for every build.

Link copied to clipboard

Starts a scan for the selected automatic or manual installation and returns its state flow.

Link copied to clipboard

Removes the scanner overlay from activity and cancels the internal coroutine scope.