5

I'm trying to send a custom accessibility event using a code similar to this one

AccessibilityManager manager = (AccessibilityManager) context
        .getSystemService(Context.ACCESSIBILITY_SERVICE);
if (manager.isEnabled()) {
    AccessibilityEvent e = AccessibilityEvent.obtain();
    e.setEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT);
    e.setClassName(getClass().getName());
    e.setPackageName(context.getPackageName());
    e.getText().add("some text");
    manager.sendAccessibilityEvent(e);
}

It's a message for an async event and I don't want the message to interrupt another one, but to play after the current message end being read by Talkback.

Any ideas?

alvarezfmb
  • 66
  • 3

1 Answers1

0

I think you can use a postDelay:

if (manager.isEnabled()) {
    AccessibilityEvent e = AccessibilityEvent.obtain();
    e.setEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT);
    e.setClassName(getClass().getName());
    e.setPackageName(context.getPackageName());
    e.getText().add("some text");
    
    new Handler().postDelay({
       manager.sendAccessibilityEvent(e);
    }, 50L)
}
Luiz Filipe Medeira
  • 1,142
  • 8
  • 13