[英]Android onTouch multi-touch not receiving all touch events
I am using an Android SurfaceView
and listening for multi-touch events. 我正在使用Android
SurfaceView
并监听多点触控事件。 I am able to detect multiple touches but it seems that the ACTION_POINTER_UP
touch event is not getting fired. 我能够检测到多个触摸,但似乎未触发
ACTION_POINTER_UP
触摸事件。 Here is a quick snip of my code. 这是我的代码的快速片段。
public class GameView extends SurfaceView implements Runnable {
...
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
Log.i("pointer count", Integer.toString(motionEvent.getPointerCount()));
return true;
}
...
}
When I put 2 fingers on the screen the pointer count log out is 2. If I remove one of my fingers the pointer count log out is not 1 and stays at 2. It only goes to 1 if I move my finger that is still on the screen. 当我将2根手指放在屏幕上时,指针计数注销为2。如果我移开一根手指,则指针计数注销将不为1并保持为2。如果我移动仍在手指上的手指,则仅变为1。屏幕。 Why is this and how to I firkin fix it?
为什么会这样,我该如何解决? thanks!
谢谢!
EDIT 编辑
This problem occurs on my One Plus One and my friends Samsung Galaxy Note 2. It is interesting that when I put it on my Samsung Galaxy s4 the problem did not occur. 我的One Plus One和我的朋友三星Galaxy Note 2上会出现此问题。有趣的是,当我将其放在我的三星Galaxy s4上时,没有发生此问题。
Do not use getAction() == MotionEvent.ACTION_POINTER_UP
as the action will also contain the pointer index. 不要使用
getAction() == MotionEvent.ACTION_POINTER_UP
因为该操作还将包含指针索引。
getActionMasked()
will strip out this information, and could be used for comparison. getActionMasked()
会删除此信息,并且可以用于比较。
See http://developer.android.com/reference/android/view/MotionEvent.html#getActionMasked() 参见http://developer.android.com/reference/android/view/MotionEvent.html#getActionMasked()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.