5

I understand the differences between the ID and Index where it seems like the ID is consistent across events, and the index can vary.

However, I keep getting changing ID's and am looking for some understanding in this area. I have read all the official android documentation, and numerous blogs, but there doesn't seem to be a concise answer.

If I put three fingers on the screen, there will be the ID's 0, 1, and 2. Those ID's will be constant for those three points as long as those fingers are on the screen. Correct?

Once a finger is lifted, say the second finger, the tracked points stay the same. There is still a point at x0, y0 and x1, y1, but the ID's are now 0 and 1. Even though the point with ID number 1 was lifted.

Is there a way to see that finger #2 lifted, and keep tracking the points using ID 0 and ID 2?

My understanding is that this needs to be done manually, and that the ID values will stay in the same order, where the second finger placed always has a higher ID than the first, but that they may not stay the same value when fingers are removed.

Nathan Tornquist
  • 6,468
  • 10
  • 47
  • 72

2 Answers2

0

The documentation says "The order in which individual pointers appear within a motion event is undefined.". So if you touch with your first, second and third finger they could actually appear in the order 0:[first]1:[third]2;[second].

You could then lift your second finger and the next motion event could be 0:[third]1:[first]. At least that is my understanding from reading of the docs, but I could be wrong.

Theblacknight
  • 575
  • 5
  • 12
0

The big problem with this is, as Theblacknight said, that the behavior is undefined. On every Android 3.0+ device I've tested so far, this works exactly like you'd expect, the IDs and indexes don't change, everything works fine.

But on Android < 3.0, it depends on the phone apparently. My Droid2 behaves like your issue there, but my friend's G2 works correctly.

I've been trying to work out the best way to handle it, but don't have a great solution just yet. If it was consistent and just swapped the point IDs once, I could accept it, but if you hold your second point and tap the first on and off, the two points swap IDs and Indexes back and forth each time. It's very frustrating.

Michael
  • 776
  • 6
  • 13