Java – Capture double-click in Android

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?



EDIT: After looking around, I think this might be more suitable for you :

// in an onUpdate method

onUpdate(float secondsElapsed){

if(seconds > 2){
touched = false;
seconds = 0;
} else{
seconds += secondsElapsed;



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
                thisTime = SystemClock.uptimeMillis();
                firstTap = false;
                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!!!!

                        Otherwise Reset firstTap
                        firstTap = true;
                    firstTap = true;
            return false;

Taken from OnTap listener implementation

Related Problems and Solutions