Search code examples
androidtouch2dmotion-detection

Android development: OnTouchEvent


I'm using:

@Override
    public boolean onTouchEvent(MotionEvent event) {

I'm using surfaceview.

But when I try:

if (event.getAction() == MotionEvent.ACTION_UP) {
    Log.d("STATE: ", "Up");

It is never called. What is the reason?

It is really annoying, because I want my player to move when I hold down the screen.


Solution

  • Ensure you are returning true return true; after you complete processing of the event (ACTION_UP in this case) and also returning super.onTouchEvent(event) for every other event (i.e. the default)?