You can try mixing MotionEvent and Runnable / Handler to achieve this.
Code example:
private final Handler handler = new Handler(); private final Runnable runnable = new Runnable() { public void run() { checkGlobalVariable(); } };
Now you only need to check if mBooleanIsPressed true in the checkGlobalVariable() function.
One of the ideas that I came up with when I wrote this was to use simple timestamps (like System.currentTimeMillis() ) to determine the duration between MotionEvent.ACTION_DOWN and MotionEvent.ACTION_UP .
Wroclai
source share