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

匆匆过客 提交于 2019-12-06 14:23:32

问题


I have an application requirement to announce text in a list view. The list view item gets added at run time. I have to announce them one by one. I searched on google and in android docs, but I could not reach there.

Please help me, how to know accessibility services finished reading the text?

Thanks :)


回答1:


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);
    }
}


来源:https://stackoverflow.com/questions/42782169/is-there-any-callback-or-anything-any-parameter-in-event-or-nodeinfo-to-know-a

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