# Get the ID of an android touch that has just ended?

**URL:** https://discourse.processing.org/t/get-the-id-of-an-android-touch-that-has-just-ended/21097
**Category:** Processing for Android
**Created:** [May 20, 2020, 2:15pm UTC](https://discourse.processing.org/t/get-the-id-of-an-android-touch-that-has-just-ended/21097 "2020-05-20T14:15:44Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Nicholas](https://avatars.discourse-cdn.com/v4/letter/n/4da419/32.png) [@Nicholas](https://discourse.processing.org/u/Nicholas)
#### Post date: [May 20, 2020, 2:15pm UTC](https://discourse.processing.org/t/get-the-id-of-an-android-touch-that-has-just-ended/21097/1 "2020-05-20T14:15:44Z")

</div>

I’m making an android app with multi touch and when a finger leaves the screen, I’d like to know which one it was because I’m tracking how long it has been since each started.

Can I do something like this:

```auto
void touchEnded(Touch t)
{
  print(t.id);
}

```

Anybody know?

Thanks

---

<div class="post-metadata">

### Author: ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)
#### Post date: [May 21, 2020, 6:14pm UTC](https://discourse.processing.org/t/get-the-id-of-an-android-touch-that-has-just-ended/21097/2 "2020-05-21T18:14:59Z")

</div>

Try and see if this code can help.

```auto
float[] old_x_touches;
float[] old_y_touches;
int tl;
boolean allow = true;

void setup() {
  fullScreen();
  orientation(PORTRAIT);
  textFont(createFont("SansSerif", 24 * displayDensity));
  textAlign(CENTER, CENTER);
}    

void draw() {
  if (allow) {
    background(255);
    for (int i = 0; i < touches.length; i++) {
      float d = (100 + 100 * touches[i].area) * displayDensity;
      fill(0, 255 * touches[i].pressure);
      ellipse(touches[i].x, touches[i].y, d, d);
      fill(255, 0, 0);
      text(touches[i].id, touches[i].x + d/2, touches[i].y - d/2);
    }
    old_x_touches = new float[touches.length];
    old_y_touches = new float[touches.length];
    for (int i = 0; i < touches.length; i++) {
      old_x_touches[i] = touches[i].x;
      old_y_touches[i] = touches[i].y;
      tl = touches.length;
    }
    for (int i = 0; i < touches.length; i++) {
      text("Touch "+i+" is "+floor(touches[i].x)+" , "+ floor(touches[i].y), width/2, 50+i*50);
    }
  }
}

void mouseDragged() {
  if (allow) {
    background(255);
    allow = false;
    for (int i = 0; i < tl; i++) {
      text("Last saved touches are "+floor(old_x_touches[i])+" , "+ floor( old_y_touches[i]), width/2, 50+i*50);
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)
#### Post date: [December 18, 2020, 7:06pm UTC](https://discourse.processing.org/t/get-the-id-of-an-android-touch-that-has-just-ended/21097/3 "2020-12-18T19:06:59Z")

</div>

Sorry, posting on the wrong topic.
