In the code below I'm testing multi touch. When the first finger touch the screen, I get the ID of that finger and if I also touch the screen with a second finger, I get that ID as well. But When I move the fingers, I only get the ID 0 and not any for ID 1, the second finger! I need to pass the id later to an method that stores the X and Y coordinates and I need to know which ID that draws on the screen.
How do I get the correct ID for the movement?
@Override
public boolean onTouch(View v, MotionEvent event) {
synchronized (gameLoop) {
for (int i = 0; i < event.getPointerCount() && i < 2; i++) {
id = event.getPointerCount();
// Check if finger touch screen
if(event.getActionIndex() == i && (event.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN || event.getActionMasked() == MotionEvent.ACTION_DOWN)) {
int j = event.getPointerCount();
int id = event.getPointerId(i);
String numDown = Integer.toString(j);
String sId = Integer.toString(id);
Log.i("Test", "Number DOWN: " + numDown + " ID: " + sId);
}
// Check if finger moves on screen
if(event.getActionIndex() == i && (event.getActionMasked() == MotionEvent.ACTION_MOVE)) {
int id = event.getPointerId(i);
String sId = Integer.toString(id);
Log.i("Test", " Moving ID: " + sId);
}
// Check if finger leave screen
if(event.getActionIndex() == i && (event.getActionMasked() == MotionEvent.ACTION_POINTER_UP || event.getActionMasked() == MotionEvent.ACTION_UP)) {
int k = event.getPointerCount();
int id = event.getPointerId(i);
String numUp = Integer.toString(k);
String sId = Integer.toString(id);
Log.i("Test", "Number UP: " + numUp + " ID: " + sId);
}
}
}
return true;
}