how can I set a contentDescription
to be read by the accessibility service when my dialog is opened? I'm currently using a dialog with a custom layout to display a blocking laoding screen and the spoken contentDescription
is "Alert", which is not appropriate in this circumstance.
Thanks ;)
You can create subclass Dialog
and override dispatchPopulateAccessibilityEvent
to provide your own accessibility text.
Here's an example:
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
event.getText().add("Your message goes here");
return true;
}
return super.dispatchPopulateAccessibilityEvent(event);
}