Detecting a long press with Android

By | August 9, 2019


I am currently using

onTouchEvent(MotionEvent event){

to detect when the user presses my glSurfaceView is there a way to detect when a long click is made. I’m guessing if I can’t find much in the dev docs then it will be some sort of work around method. Something like registering ACTION_DOWN and seeing how long it is before ACTION_UP.

How do you detect long presses on android using opengl-es?


Try this:

final GestureDetector gestureDetector = new GestureDetector(new GestureDetector.SimpleOnGestureListener() {
    public void onLongPress(MotionEvent e) {
        Log.e("", "Longpress detected");

public boolean onTouchEvent(MotionEvent event) {
    return gestureDetector.onTouchEvent(event);

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *