tags:

views:

233

answers:

2

I have two buttons that both have onTouchListeners and perform an action when pressed down. Why do they not work if you try to click both at the same time? I'm building for Android 1.6. I don't have a real device to test on, and you can't test clicking two things at the same time in the emulator. Thanks for any help.

A: 

I'm no expert, but my guess would be the following,

All gui-interaction is done through the UI-thread. Unless you do some special treatment of the buttons, you'll end up processing "click 1" with the UI-thread, while the user does "click 2" (at a time when the UI-thread is busy somewhere else). That is, the UI will not be responsive during the second click.

aioobe
How would I do special treatment of the buttons to handle two clicks at the same time?
sw333t
I'm not sure. You would definitely have to read up on the multi-touch api-methods.
aioobe
Looks like someone else had the same question which was never fully answered: http://stackoverflow.com/questions/2528160/multiple-button-presses-for-android-2-x
sw333t
A: 

Multitouch was only introduced in Android 2.x, so on 1.6 you're out of luck - not possible. Even with 2.x the default UI behavior is to be singletouch only for such events (ie button press).

I suppose it is possible to somehow extend the container view of those buttons to become multitouch friendly and actually pass the correct events to the buttons, but that would be quite hackish.

You can read more about multitouch here. And on page 3 you can see why the multitouch fails on the GUI: first touch event is ACTION_DOWN which is handled like it should be, and the second one is ACTION_POINTER_DOWN which the UI doesn't know how to handle.

Roosmaa