I am working on a simple android app, my Requirement is,
"After some move events(MotionEvent.ACTION_MOVE is true) on the screen, if the user stops moving for few seconds some where with out taking finger from the screen, then need to perform some action."
*I learnt that LongPress is something which triggers when user doesn't make any move after the down event is triggered(MotionEvent.ACTION_DOWN).*
So is there any way to trigger LongPress after Moving around in the screen?
Or should I create my own listener for the same functionality??
Any help is appreciated.
Thank you.
Idea is to
cancel
the timer everytime you move finger on screen(MotionEvent.ACTION_MOVE
). When you stop moving after some time, say after 3 seconds, timer code will get executed, in which you can do long press task. If you stop moving for some time and again start moving before elapse time (3 sec), again new timer is set and so on. Hope it helps you.i'm afraid you will have to do it on your own. The default implementation is to trigger the long press event only if there is no Move event
the key is to use
System.getCurrentTime()
inonTouchEvent()
How?
in
onTouch()
look for Motion_DOWN event,
long
variable) the time of touch event. (useSystem.getCurrentTime()
)isClicked
to true)isClicked
is still true. Think of it as your onLongClick Listener--
EDIT: i missed one important step :