So I\'m developing an application that must handle multitouch. Basically I want single touch for rotating ( this is no problem ). And multitouch for scrolling.
I h
You can solve this with simple math, although there may be a better way already built in.
Just create an object that holds the position of each finger when the .ACTION_POINTER_X_UP event fires and a boolean object that holds which type of touchmode you last used.
case MotionEvent.ACTION_POINTER_1_UP:
camera.onTouchDown( xEvent[ 1 ], yEvent[ 1 ] );
boolean usedMultiTouch = true;
int x = event.getX(1);
int y = event.getY(1);
return true;
Next your ACTION_MOVE (inside the case=1) statement will fire as the user moves their finger as they went from multi to single touch.
Now, depending on what you want to do, you can either ignore the single move (the boolean is your check) until the .ACTION_UP event fires and you set the boolean back to false
or
you call a method that does some math based on the saved location values and the finger that is still on the screen. The math should be pretty easy, but I don't know what you actually want to do.
Start here if you haven't read it already, it goes over a number of things dealing with multitouch in Android: http://android-developers.blogspot.com/2010/06/making-sense-of-multitouch.html
A few things about your posted code:
ACTION_DOWN
with a pointer count of 2. ACTION_DOWN
is only sent for the first pointer that goes down. All fingers that touch the screen after the first will send ACTION_POINTER_DOWN
.MotionEvent#getActionMasked()
) than to code for each pointer index individually.MotionEvent
. If you're tracking pointer movement over time, use the pointer ID.