我正在为盲人社区开发一个 android 应用程序。在我的应用程序中,我正在处理所有带有 TTS/音频文件的点击/触摸。它工作正常,但是当用户打开 TalkBack 功能时,所有的点击/触摸都需要两次。首先,它将由 TalkBack 决定,然后是我的内部机制。
我能够检测到 TalkBack 是否启用。
public boolean accessibilityEnable(Context context) {
boolean enable = false;
Log.e("Reached before function", "yes");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
try {
AccessibilityManager manager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
List<AccessibilityServiceInfo> serviceList = manager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_SPOKEN);
Log.e("Reached before for loop", "yes");
for (AccessibilityServiceInfo serviceInfo : serviceList) {
String name = serviceInfo.getSettingsActivityName();
if (!TextUtils.isEmpty(name) && name.equals(TALKBACK_SETTING_ACTIVITY_NAME)) {
enable = true;
Log.e("Reached after if loop", "yes");
}
}
Log.e("Reached after for loop", "yes");
} catch (Exception e) {
Log.e("Error", "Error aaya re");
}
}
return enable;
}
我想在我的应用程序处于活动状态时禁用对讲功能?