Android multitouch?

dakira picture dakira · Jan 17, 2011 · Viewed 15.4k times · Source

As a developer, I tend to program first then research later. I was trying to implement a screen that would handle multiple user inputs. Basically map more than just one finger. I tried two things..

I had an Activity class that implemented OnTouchListener. Here I had two separate child views that added the Activity as their ontouch listeners. And then I had a print line that printed out the event.getPointerCount() and printed out the location of each of the pointers..

Downloaded it to the phone and tested it. I noticed that the pointers never grew greater than two. I even noticed if one finger was on one child and another finger on the other child view that the events only made it to the first child component. Next I tried to put separate listeners on each of the child components to see if that would work but it acted the same.

So, it seems that the android only supports a total of two user inputs when dealing with inputs from the user touching the screen.

Is this true? It seems from testing and research that this is the case.

Has anyone ran into this limitation. Any clever work arounds?

Thanks for you time and responses.

dk

Answer

adamp picture adamp · Jan 17, 2011

The number of touch points supported is dependent on the device. In all currently available versions of Android MotionEvents are sent to a single target view and describe the state of all currently active touch points. The target view is determined by where the first MotionEvent.ACTION_DOWN event occurs.

See the post Making Sense of Multitouch on the Android Developers blog for a quick overview of working with multitouch events on Android.