是否有任何回调或其他任何东西(事件或nodeInfo中的任何参数)知道可访问性服务(TalkBack)已完成读取? [英] Is there any callback or anything (any parameter in event or nodeInfo) to know accessibility service (TalkBack) has finished reading?

查看:72
本文介绍了是否有任何回调或其他任何东西(事件或nodeInfo中的任何参数)知道可访问性服务(TalkBack)已完成读取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用要求,需要在列表视图中宣布文本。列表视图项在运行时添加。我必须一一宣布。我在google和android docs中进行了搜索,但我无法到达那里。

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?

谢谢:)

推荐答案

简单的答案...不要这样!这是愚蠢的。只需使用您可用的辅助功能,然后让TalkBack(或其他潜在的屏幕阅读器)为您管理它即可。只需使用此实用程序功能即可。

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

这篇关于是否有任何回调或其他任何东西(事件或nodeInfo中的任何参数)知道可访问性服务(TalkBack)已完成读取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆