Is there any callback or anything (any parameter in event or nodeInfo) to know accessibility service (TalkBack) has finished reading?

懵懂的女人 提交于 2019-12-04 18:22:10

Simple answer... don't do it this way! This is silliness. Just use the accessibility features available to you and let TalkBack (or other potential screen reader) manage it for you. Just use this utility function.

public static void announceForAccessibility(Context context, String message) {
    AccessibilityManager manager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);

    if (manager.isEnabled()) {

        AccessibilityEvent e = AccessibilityEvent.obtain();
        e.setEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT);
        e.setClassName(context.getClass().getName());
        e.setPackageName(context.getPackageName());
        e.getText().add(message);

        manager.sendAccessibilityEvent(e);
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!