So, I’m developing an app and need to have two buttons pressed at the same time.
I need the events for the buttons to be triggered when pressed(which is at the same time, too).
Imagine a car – I have left, right, forward and back. I need to press EG. forward and right together to make a right turn.
Here is my method but for some reason when I press both buttons, only the one pressed first is triggered… Any ideas?
// Handle touches of the navigation arrows
public boolean onTouch(View v, MotionEvent theMotion) {
switch (theMotion.getAction()) {
// A button was PRESSED
case MotionEvent.ACTION_DOWN:
switch (v.getId()) { // Which button?
case R.id.freestyle_upArrow: // The upArrow
bt.sendNXTcommand(MOTOR_B_FORWARD, 720);
break;
case R.id.freestyle_downArrow: // The downArrow
bt.sendNXTcommand(MOTOR_B_BACKWARD, 720);
break;
case R.id.freestyle_leftArrow: // The leftArrow
bt.sendNXTcommand(MOTOR_A_LEFT, 720);
break;
case R.id.freestyle_rightArrow: // The rightArrow
bt.sendNXTcommand(MOTOR_A_RIGHT, 720);
break;
}
break;
// A button was RELEASED
case MotionEvent.ACTION_UP:
switch (v.getId()) { // Which button?
case R.id.freestyle_upArrow: // The upArrow
bt.sendNXTcommand(MOTOR_B_STOP, 0);
break;
case R.id.freestyle_downArrow: // The downArrow
bt.sendNXTcommand(MOTOR_B_STOP, 0);
break;
case R.id.freestyle_leftArrow: // The leftArrow
break;
case R.id.freestyle_rightArrow: // The rightArrow
break;
}
break;
}
return true;
}
So, any have any ideas? Does it have something to do with the number of points allowed on my screen?
PHONE SPECS: Samsung Galaxy Ace running Android OS on firmware 2.2.1
Regards,
Rich.
Using
You want to look for
For the second finger. Keep in mind you will get a ACTION_POINTER_UP no matter which finger is lifted first