Is there any way to detect Android event like holding finger on screen but without moving? When I override function onTouch
I can detect 3 types of events: ACTION_DOWN
, ACTION_MOVE
, ACTION_UP
but when the user holds finger on screen without moving there isn't emitted any action. Is there any function which I can override to detect such an event?
Asked
Active
Viewed 535 times
0

iknow
- 8,358
- 12
- 41
- 68
-
1https://stackoverflow.com/questions/7919865/detecting-a-long-press-with-android plz check this – pallavi richhariya Jun 30 '20 at 17:34
1 Answers
1
First off- you're almost never not moving. Even if you aren't moving, small variations in the capacity of your finger and the shape of the contact with the screen will make it look like you're moving. So you'll be getting a constant stream of move events.
Secondly- until you get an ACTION_UP or ACTION_CANCEL, you're still touching the device. So you basically just set a timer for however long you want to wait when you see a down, and cancel it when you see UP, CANCEL, or a MOVE that seems too big (you define what that threshold is). If the timer goes off, then you were holding your finger in one spot.

Gabe Sechan
- 90,003
- 9
- 87
- 127
-
You are right, I am always moving when I hold finger on screen of a physics device. When at the beginning I was testing `onTouch` event on the emulator it wasn't detected because the mouse cursor was only at one pixel. – iknow Jul 01 '20 at 10:06