user2080326
user2080326

Reputation: 21

Android Multitouch control

I am trying to make a mulitouch control, but i always get errors when I remove my finger in a different sequence, as I give it to the screen.

@Override
public boolean onTouchEvent(MotionEvent event) {
    pointers = event.getPointerCount();
    for(int a = 0; a < event.getPointerCount(); a++) {
        expos[a] = (int) event.getX(event.getPointerId(a));
        eypos[a] = (int) event.getY(event.getPointerId(a));
    }
    if(event.getAction() == MotionEvent.ACTION_DOWN) pressed = true;
    if(event.getAction() == MotionEvent.ACTION_UP) pressed = false;
    return true;
}

I think the problem is that when i remove the first finger the second one still has the id 2, but what can i do to fix it?

Upvotes: 1

Views: 253

Answers (1)

vicciu
vicciu

Reputation: 164

As I understand, the problem is that you don't get the ACTION_UP event when you release one of the fingers. The solution to this is to use ACTION_POINTER_UP. It will detect releases of any non-primary pointers and should solve the problem

Upvotes: 1

Related Questions