问题
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?
回答1:
You don't. It's a terrible idea. Come up with gestures and mechanisms that fit within what TalkBack allows. If you could annotate a specific feature or mechanism of your app that is not allowed to work with talkback, I could recommend an alternative. What gesture is it that's not working?
回答2:
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);
}
}
And handle hover action to 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 :)
来源:https://stackoverflow.com/questions/35165206/how-to-stop-touch-to-explore-feature-of-talkback-in-my-app