I have onLongPress and onDoubleTap actions placed on the button according to this code:
...
GestureDetector detector = new GestureDetector(this, new TapDetec
Technically this shouldn't happen
case MotionEvent.ACTION_DOWN:
mLastMotionX = x;
mLastMotionY = y;
mCurrentDownEvent = MotionEvent.obtain(ev);
mAlwaysInTapRegion = true;
mInLongPress = false;
if (mIsLongpressEnabled) {
mHandler.removeMessages(LONG_PRESS);
mHandler.sendEmptyMessageAtTime(LONG_PRESS, mCurrentDownEvent.getDownTime()
+ tapTime + longpressTime);
}
mHandler.sendEmptyMessageAtTime(SHOW_PRESS, mCurrentDownEvent.getDownTime() + tapTime);
because on the ACTION_DOWN or ACTION_UP event, all of the LONG_PRESS messages events are removed from the queue. So on the second tap the following code will remove the long press events.
mHandler.removeMessages(LONG_PRESS);
Ninja edit : hacky workaround for your problem
@Override
public void onLongPress(MotionEvent e) {
if(MainActivity.this.hasWindowFocus())
{
Log.d("Touchy", "Long tap");
}
}
You see always the onLongPress fired because in your code you launch an intent before of consuming the onDoubleTap event.
You can disable onLongPress by
public void setIsLongpressEnabled (boolean isLongpressEnabled)
and use the onDown method for performing your action.