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)
}
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
}
))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.