I am trying to catch a LongPress-Gesture in my Android App, but the this.gestureDetector.onTouchEvent(event) returns always false. I get the "Longpress detected" in LogCat, but onTouchEvent always return false - any ideas what's wrong here?
final GestureDetector gestureDetector = new GestureDetector(this.getContext(),
new GestureDetector.SimpleOnGestureListener() {
@Override
public void onLongPress(MotionEvent event) {
Log.e(TAG, "Longpress detected");
}
});
@Override
public boolean onTouchEvent(MotionEvent event) {
boolean test = this.gestureDetector.onTouchEvent(event);
Log.v(TAG, Boolean.toString(test)); // test is _always_ false
if (test) {
// Do something
return test;
}
return super.onTouchEvent(event);
}
Because onLongPress has no return value, it is defined void.