Search code examples
androidtouchscreen

How to avoid lines between multiple touches?


I am testing this sample on version 13 of android (3.2) and I have an issue when there is multiple touches on screen.

When I first touch, then there is an action_down event, if I make another simultaneous touch, then I won't get another action_down, my first touch keeps active and I can keep getting action_move from the first touch. The problem is, when I release the first touch and move the second, it creates a line to that touch, because it generates another action_move event. I tried using Euclidean distance, but it seems to slow down too much, and makes the lines incomplete. I tried creating a producer/consumer model, but still got the same problem. I also tried checking the time from the last touch, but this is very inefficient.

Does anyone have any suggestion?


Solution

  • I admit I'm a little confused about what your actual problem is, but it seems to me like your problem might be solved simply by handling more of the touch events. When the second finger comes down, you can get an ACTION_POINTER_DOWN event, indicating a second touch, and you can then modify how your ACTION_MOVE events will be interpreted while the second finger is down, until an ACTION_POINTER_UP event comes through. Hope that answers or at least helps your question.