title: Get coordinates from multiple fingers (Android)
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/11910223/pointer-problems-android">Pointer problems! (Android)</a>  </p>
  </blockquote>
  
  
  
  <p>I've been searching everywhere for a code that simply obtains one X- and one Y-value for each pointer and perhaps some different boolean variables for each pointer to easily understand what is happening. </p>
  
  <p>I've been working on a code myself, but it doesn't work quite as I want to. It will save four different pair of X- and Y-coordinates, but the problem is that whenever one finger is removed from the screen, all of the pointers (in the boolean touching[]) becomes false for a while. Does anyone know how to make each pointer individual, so that when one finger is removed from the screen only that value in the boolean array will become false? </p>
  
  <pre><code>public boolean onTouch(View v, MotionEvent event) {
      // TODO Auto-generated method stub
      int action = (event.getAction() &amp; MotionEvent.ACTION_MASK);
      int pointCount = event.getPointerCount();
  
      for (int i = 0; i &lt; pointCount; i++) {
          int id = event.getPointerId(i);
  
          if (id &lt; MAX_NUMBER_OF_POINT) {
  
              xA[id] = (int) event.getX(i);
              yA[id] = (int) event.getY(i);
  
              if ((action == MotionEvent.ACTION_DOWN)
                      || (action == MotionEvent.ACTION_POINTER_DOWN)
                      || (action == MotionEvent.ACTION_MOVE)) {
                  touching[id] = true;
              } else {
  
                  touching[id] = false;
              }
          }
      }
  
  
      for (int i2 = 0; i2 &lt; 5; i2++) {
          if (touching[i2] == false) {
  
              xA[i2] = 0;
              yA[i2] = 0;
          }
      }
  
      x1 = xA[0];
      x2 = xA[1];
      x3 = xA[2];
      x4 = xA[3];
  
      y1 = yA[0];
      y2 = yA[1];
      y3 = yA[2];
      y4 = yA[3];
  
      return true;
  }
  </code></pre>
  
  <p>Thanks!</p>