Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ACTION_UP even never called

I'm trying to make a small android Jump and Run game but my problem is that i can't configure the event ACTION_UP right. Here my Code:

public boolean onTouchEvent(MotionEvent event) {
    switch(event.getAction()){
    case MotionEvent.ACTION_DOWN:
        Log.d("OTE", "down"); 
        touchDownTrue = true;
        break;
    case MotionEvent.ACTION_UP:
        Log.d("OTE", "UP"); 
        touchDownTrue = false;
        break;
    }
}

the case MotionEvent.ACTION_UP is never called and i don't know why, the same happens if i use ACTION_CANCEL

like image 458
M364M4N cro Avatar asked Oct 24 '11 18:10

M364M4N cro


1 Answers

After I insert return super.onTouchEvent(event); at the end of the method (onTouchEvent must return a value) your code works for me, when I put it in a blank main activity.

You should probably return true instead of breaking in those cases because you are responding to the event.

like image 192
skynet Avatar answered Sep 22 '22 12:09

skynet