我为百叶窗开发了一个应用程序,我需要检测当TalkBack打开时点击屏幕上的点数。 (当isTouchExplorationEnabled为true时)。如果有人知道答案,你可以帮助我。感谢您的帮助。
到目前为止尝试过的代码..
private class MytempClass extends View {
Context context;
public MytempClass(Context context) {
super(context);
this.context = context;
}
@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);
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
int x = event.getPointerCount();
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_HOVER_ENTER:
case MotionEvent.ACTION_POINTER_DOWN:
Toast.makeText(MyActivity.this, event.getX() + "- num of points" + x, Toast.LENGTH_LONG).show();
break;
case MotionEvent.ACTION_MOVE:
case MotionEvent.ACTION_HOVER_MOVE:
//code
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_HOVER_EXIT:
//code
break;
}
return true;
}
}