如何在我的应用程序中停止“话语提示"的“触摸浏览"功能 [英] How to stop Touch To Explore feature of TalkBack in my app

查看:202
本文介绍了如何在我的应用程序中停止“话语提示"的“触摸浏览"功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为盲人开发一个项目,如果用户在手机上激活TalkBalk,我需要解决很多麻烦.

I'm working on a project for blind people, there're a lot of troubles I need to fix if the user activates TalkBalk on his phone.

我正在为盲人创建一个软键盘,盲人将用一根手指在圆圈上敲击盲文单元点"以生成盲文代码,然后他输入要显示的字符/数字/符号盲文语言.

I'm creating a soft keyboard for blind people, the blind will tap with single finger on the circles "Braille Cell Dots" to generate a Braille code, then he types the character/number/symbols he wants as they presented in Braille language.

我现在的问题是话语提示"的触摸浏览"功能,用户将无法在屏幕上单击,因为此操作现在由话语提示"处理,用户必须在点上点按两次,这对我的应用!

My problem now is Touch To Explore feature of TalkBack, the user will not be able to make a single tap on the screen because this action now handled by TalkBack, the user must double tap on the dot and this is not good for my app!

即使在话语提示"中启用了触摸浏览"功能,如何生成单击?

How to generate a single tap even if Touch to Explore feature is enabled in TalkBack?

推荐答案

基于此答案已解决了我的问题,因为如果启用了触摸探索功能,将单次触摸事件转换为悬停事件,所以我添加了 onHoverEvent 来调用 onTouchEvent 并可以正常工作:

Based on this answer which has solved my problem, as the single touch event converted to hover event if touch to explore is enabled, I've added onHoverEvent to call onTouchEvent and works fine:

@Override
public boolean onHoverEvent(MotionEvent event) {
    //Move AccessibilityManager object to the constructor 
    AccessibilityManager am = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (am.isTouchExplorationEnabled()) {
        return onTouchEvent(event);
    } else {
        return super.onHoverEvent(event);
    }
}

并处理对 onTouchEvent 的悬停操作:

@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
    case MotionEvent.ACTION_HOVER_ENTER:
    //Your Code
    break;
    case MotionEvent.ACTION_MOVE:
    case MotionEvent.ACTION_HOVER_MOVE:
    //Your Code
    break;
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_HOVER_EXIT:
    //Your Code
    break;    

}

return true;
}

我将编辑我的问题以使其更干净:)

I'll edit my question to be more cleaner :)

这篇关于如何在我的应用程序中停止“话语提示"的“触摸浏览"功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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