Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android 3 finger touch detection

I am successfully able to record the coordinates of the two fingers being touched on the screen using the following code:

case MotionEvent.ACTION_MOVE:
Log.d("TOUCH", "test ACTION MOVE" + event.getPointerCount());
Log.d("TOUCH", "test ACTION MOVE ID" + event.getPointerId(0) + " "+event.getPointerId(1));
if(event.getPointerCount()==3)
{

x0 = (int) event.getX(event.getPointerId(0));
y0 = (int) event.getY(event.getPointerId(0));
x1 = (int) event.getX(event.getPointerId(1));
y1 = (int) event.getY(event.getPointerId(1));
x2 = (int) event.getX(event.getPointerId(2));
y2 = (int) event.getY(event.getPointerId(2));

Log.d("TOUCH", "test ACTION DOWN " + " values = " + x0 + " " + y0 + " "
+ x1 + " " + y1+ " "+x2 + " " + y2);
}

But In the above code im not able to detect more then 2 touch points at a single instance. Even the pointerCount() never goes above 2.

How can I get the touch coordinates for more then 2 fingers? Im running this code on Android 2.2

like image 421
Kshitij Aggarwal Avatar asked May 05 '11 06:05

Kshitij Aggarwal


People also ask

How do I turn on multiple touch on Android?

Introducing multi-touch That's called a "tap" gesture. Another gesture is called "drag". That's where you hold one finger on the screen and move it around, causing the content under your finger to scroll. Tap, drag, and a few other single-fingered gestures have always been supported in Android.


2 Answers

This was asked some time ago, but anyway. The answer is that although android could track 256 fingers, the current implementation limits this to 2 fingers.

I'm not sure about honeycomb, but I guess that it has the same "issue".

like image 69
Augusto Avatar answered Oct 18 '22 07:10

Augusto


I've confirmed 4 touches on some Android 2.3.5 devices, and every 3.x and 4.x device I've tested so far. It seems that at least from API 8+, more than two touches is supported, but it's device-dependent.

like image 28
Michael Avatar answered Oct 18 '22 05:10

Michael