Android Double-Click Capture

I am recording an onSceneTouchEvent event using AndEngine.

What I want to do does not allow to capture the user by double-clicking on the screen.

In any case, to detect double taps or disable them?

thanks

+4
source share
1 answer

EDIT: Looking around a bit more, I think this might be better for you:

// in an onUpdate method onUpdate(float secondsElapsed){ if(touched){ if(seconds > 2){ doSomething(); touched = false; seconds = 0; } else{ seconds += secondsElapsed; } } } 

Taken from: http://www.andengine.org/forums/gles1/delay-in-touchevent-t6087.html

Based on the comment above, I'm sure that with SystemClock you can pay for the following:

You can get away with the addition of a delay, something 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 the implementation of the OnTap listener

+3
source

Source: https://habr.com/ru/post/1390963/


All Articles