mildog8
mildog8

Reputation: 2154

Android onTouch multi-touch not receiving all touch events

I am using an Android SurfaceView and listening for multi-touch events. I am able to detect multiple touches but it seems that the ACTION_POINTER_UP touch event is not getting fired. 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. 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.

Upvotes: 1

Views: 1089

Answers (1)

Arve
Arve

Reputation: 8128

Do not use getAction() == MotionEvent.ACTION_POINTER_UP as the action will also contain the pointer index.

getActionMasked() will strip out this information, and could be used for comparison.

See http://developer.android.com/reference/android/view/MotionEvent.html#getActionMasked()

Upvotes: 2

Related Questions