宣布可访问性不起作用 [英] announceforaccessibility is not working
问题描述
我正在尝试为视障人士开发应用程序,我正在使用可访问性来确保
我正在尝试为用户设置欢迎语,而无需用户触摸仅应在可访问性中播放的内容模式,当活动启动
i时,有一个 Textview
会欢迎用户,并且我已在 contentDescription $ c $中设置了该消息c>其中的
和 onCreate
方法调用
i'm trying to develop an application for visually impaired people, i'm using accessibility for sure
i'm trying to set a welcome for the user without the user touching anything that should be played only in accessibility mode and when the activity launches
i have a Textview
that welcomes the user and i have set the message in the contentDescription
of it
and onCreate
method i call
textView.announceForAccessibility("Welcome");
我也尝试过
textView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
textView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
textView.sendAccessibilityEvent(AccessibilityEvent.TYPE_ANNOUNCEMENT);
以及几乎每个 AccessibilityEvent类型
工作
我正在用启用了辅助功能的android v7在nexus6p上进行测试
and almost every AccessibilityEvent type
none of them works
i'm testing on nexus6p with android v7 also with accessibility enabled
推荐答案
感谢此线程早些时候,我找到了答案
我所做的一切我都添加了此代码段的代码,它就像魅力
Thanks to this thread earlier i ave found the answer all i did i added this snippet of code and it worked like charm
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屋!