3

I am trying to implement handwritten character recognition in Android.

My code has 3 Listeners: onTouch, onDrag and onRemove (So I can get the list of coordinates based on Drag Event). Since for some characters we need to lift up our finger for a small time (eg. for caps K or H, but in my case it's not English characters), but as soon as I lift up my finger from screen it calls remove listener, i want to delay the drag listener for few milliseconds, so that I can get the complete set of coordinates before calling remove listener. Is it possible to delay it, or is there any simple way to achieve this task?

TheCodeArtist
  • 21,479
  • 4
  • 69
  • 130
Ajeet
  • 31
  • 2
  • Welcome to SO! I tried making your post a bit clearer, but I must say that it's still hard to understand. Please try to re-word it so that it's easy to understand what you're trying to achieve. – Camilo Martin May 23 '13 at 23:34

1 Answers1

2

Right answer is not Timer, because it will create extra Thread to do simple thing. Because you mentioned

delay the drag listener for few milliseconds

It's good to use Handler and postDelayed which takes Runnable/task you try to delay and long/delay timeout.

Volodymyr Lykhonis
  • 2,936
  • 2
  • 17
  • 13
  • Let's say I have a surface view in which override `onTouch` Method is there. Till the time I am touching my view, I am getting set of coordinates in this session. As soon as I pull out my touch, it starts new session, I want to delay this for few milliseconds and if I touch the view again within the delay, the next set of coordinates along with previous coordinates should come in single session. Is it possible? – Ajeet May 26 '13 at 00:48