Capture double-click in Android… here is a solution to the problem.
Capture double-click in Android
I’m using AndEngine to capture onSceneTouchEvent events.
What I want to do is not allow it to capture the user double-clicking screen.
Is there a way to detect double clicks or disable them?
Thanks
Solution
EDIT: After looking around, I think this might be more suitable for you :
// in an onUpdate method
onUpdate(float secondsElapsed){
if(touched){
if(seconds > 2){
doSomething();
touched = false;
seconds = 0;
} else{
seconds += secondsElapsed;
}
}
}
From: http://www.andengine.org/forums/gles1/delay-in-touchevent-t6087.html
Based on the comments above, I believe you can also use SystemClock to mess up with the following methods.
You can add a delay, similar to this:
public boolean onTouch(View v, MotionEvent event) {
TODO Auto-generated method stub
if(firstTap){
thisTime = SystemClock.uptimeMillis();
firstTap = false;
}else{
prevTime = thisTime;
thisTime = SystemClock.uptimeMillis();
Check that thisTime is greater than prevTime
just incase system clock reset to zero
if(thisTime > prevTime){
Check if times are within our max delay
if((thisTime - prevTime) <= DOUBLE_CLICK_MAX_DELAY){
We have detected a double tap!
Toast.makeText(DoubleTapActivity.this, "DOUBLE TAP DETECTED!!!", Toast.LENGTH_LONG).show();
PUT YOUR LOGIC HERE!!!!
}else{
Otherwise Reset firstTap
firstTap = true;
}
}else{
firstTap = true;
}
}
return false;
}
Taken from OnTap listener implementation