Here is the scenario of my problem:
-I press down on the screen. I can keep track of this touch event with the ACTION_DOWN variable of the MotionEvent class. My problem comes when I keep this initial finger pressed on the screen. I want to be able to track any other touch events on the screen.
I think my question is essentially, how can I keep track of subsequent touch events even while one is going on?
Best,
Aneem
EDIT:
public boolean onTouchEvent(final MotionEvent ev) {
if(ev.getAction()==ev.ACTION_DOWN||ev.getActionMasked()==ev.ACTION_POINTER_DOWN){
AudioManager mgr = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
int streamVolume = mgr.getStreamVolume(AudioManager.STREAM_MUSIC);
PointF[] touchPoints = new PointF[ev.getPointerCount()];
for(int i = 0; i < ev.getPointerCount(); i++){
touchPoints[i] = new PointF(ev.getX(i),ev.getY(i));
}
for(final PointF point : touchPoints){
x = ev.getX(ev.getActionIndex());
y = ev.getY(ev.getActionIndex());
int ptx = (int) (x - x%widthIncrement);
int pty = (int) (y - y%heightIncrement);
playSound(pointMap.get(new Point(ptx,pty)));
}
return true;
}
return true;
}
Well, you can determine if a non-primary pointer (another finger likely) has gone down the same way except instead of looking for the ACTION_DOWN, look for the ACTION_POINTER_DOWN.