Take the 2-minute tour ×

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.

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?

share|improve this question
add comment

1 Answer

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

share|improve this answer
But with ACTION_POINTER_UP i only know when the pointers are removed in a different sequence. How can i make the pointer 2 to pointer 1 when pointer 1 is removed? –  user2080326 Feb 17 '13 at 13:56
This is done automatically. The problem id that you use getPointerID, but you don't need it. Instead of: expos[a] = (int) event.getX(event.getPointerId(a)); you have to write: expos[a] = (int) event.getX(a); –  vicciu Feb 17 '13 at 14:03
add comment

Your Answer


