Understanding Multitouch in Android
<p>I have been studying multitouch on android but i got couldn't understand some of the lines i found.i searched google but couldn't find that understandable resources. i am posting the code.</p>

<p>I understand most of the part except "first two lines of <code>onTouch</code> method", <code>if (event.getAction() != MotionEvent.ACTION_MOVE &amp;&amp; i != pointerIndex)</code> and <code>case MotionEvent.ACTION_MOVE:</code></p>

<p>Please explain them.
Thanks for your help~~</p>

<pre><code>package --- ;

--imports--

@TargetApi(5)
public class MultiTouchTest extends Activity implements OnTouchListener {
StringBuilder builder = new StringBuilder();
TextView textView;
float[] x = new float[10];
float[] y = new float[10];
boolean[] touched = new boolean[10];
int[] id = new int[10];

private void updateTextView() {
    builder.setLength(0);
    for (int i = 0; i &lt; 10; i++) { 
        builder.append(touched[i]);
        builder.append(", ");
        builder.append(id[i]);
        builder.append(", ");
        builder.append(x[i]);
        builder.append(", ");
        builder.append(y[i]);
        builder.append("\n");
    }
    textView.setText(builder.toString());
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    textView = new TextView(this);
    textView.setText("Touch and drag(multiple fingers supported!");
    textView.setOnTouchListener(this);
    setContentView(textView);
    for (int i = 0; i &lt; 10; i++) {
        id[i] = -1; 
    }
    updateTextView();
}

@Override
public boolean onTouch(View v, MotionEvent event) {
    int action = event.getAction() &amp; MotionEvent.ACTION_MASK; 
    int pointerIndex = (event.getAction() &amp; MotionEvent.ACTION_POINTER_ID_MASK) &gt;&gt; MotionEvent.ACTION_POINTER_ID_SHIFT; 
    int pointerCount = event.getPointerCount(); 
    for (int i = 0; i &lt; 10; i++) { 
        if (i &gt;= pointerCount) {
            touched[i] = false;
            id[i] = -1;
            continue;
        }

        if (event.getAction() != MotionEvent.ACTION_MOVE
                &amp;&amp; i != pointerIndex) { 

            continue;
        }
        int pointerId = event.getPointerId(i);
        switch (action) {
        case MotionEvent.ACTION_DOWN:
        case MotionEvent.ACTION_POINTER_DOWN:
            touched[i] = true;
            id[i] = pointerId;
            x[i] = (int) event.getX(i);
            y[i] = (int) event.getY(i);
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_POINTER_UP:
        case MotionEvent.ACTION_OUTSIDE:
        case MotionEvent.ACTION_CANCEL:
            touched[i] = false;
            id[i] = -1;
            x[i] = (int) event.getX(i);
            y[i] = (int) event.getY(i);
            break;
        case MotionEvent.ACTION_MOVE:
            touched[i] = true;
            id[i] = pointerId;
            x[i] = (int) event.getX(i);
            y[i] = (int) event.getY(i);
            break;
        }

    }
    updateTextView();

    return true;
}
}
</code></pre>
