4

Trying to announce accessibility when showing a pop up/Dialog. After hours of searching found the following code but this does not work for jetpack compose.

Looking for something similar to the code given below but in Jetpack Compose

if (manager.isEnabled) {
    val e = AccessibilityEvent.obtain()
    e.eventType = AccessibilityEvent.TYPE_ANNOUNCEMENT
    e.className = ChangePassword::class.java.name
    e.packageName = context.packageName
    e.text.add(errorMessage)
    manager.sendAccessibilityEvent(e)
}
Kinjal Rathod
  • 499
  • 4
  • 12

1 Answers1

6

For all those looking for an answer, there's one simple property in Jetpack Compose that will work. Which is liveRegion

You can find the documentation here: https://developer.android.com/reference/kotlin/androidx/compose/ui/semantics/LiveRegionMode

and it can be used as follow;

Text(modifier = Text(
                text = "Page Title,
                color = White,
                modifier = Modifier
                    .focusable()
                    .clearAndSetSemantics {
                        this.contentDescription = accSkipPermission
                        liveRegion = LiveRegionMode.Assertive
                    }
            ))
Kinjal Rathod
  • 499
  • 4
  • 12