Android JazzHand device triggers MouseEvent.ACTION_UP when fingers are still on screen

202 views Asked by At

I am testing different multitouch tracking on different Android phones. A Motorola Moto G running Android KitKat 4.4.4 has the JazzHand feature: it responds to 5 simultaneous screen touches. However, sometimes when two or more fingers are still on the screen, it stops responding to touch.

From time to time, a MotionEvent which responds to getActionMasked() with MouseEvent.ACTION_UP is triggered while fingers are still on the screen. From that point on, no additional touches are detected. You have to lift all your fingers and then start over.

I'm using a basic Hello World project, with minor changes to debug this. The contents of the activity_main.xml and the MainActivity.java files are shown below. The output should be a list of touch points. When you lift your fingers, the output should go blank. However, this also happens sometimes as you are moving your fingers on the screen.

I would be grateful if you could test this on your own multitouch Android device(s), to let me know if this occurs on other device models too. If you can provide an explanation or a workaround, that would be much appreciated.


activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:paddingLeft="@dimen/activity_horizontal_margin"
                android:paddingRight="@dimen/activity_horizontal_margin"
                android:paddingTop="@dimen/activity_vertical_margin"
                android:paddingBottom="@dimen/activity_vertical_margin"
                tools:context=".MainActivity">

    <TextView
        android:text="@string/hello_world"
        android:id="@+id/text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

</RelativeLayout>

MainActivity.java

import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.widget.TextView;


public class MainActivity extends Activity {

    private TextView textView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textView = (TextView) findViewById(R.id.text_view);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {

        String points = "";
        int action = event.getActionMasked();

        if (action == MotionEvent.ACTION_CANCEL) {
            points = "Action cancelled";
        } else if (action != MotionEvent.ACTION_UP) {
            int size = event.getPointerCount();

            for (int ii = 0; ii < size; ii++) {
                points += "\n(" + event.getX(ii) + ", " + event.getY(ii) + ")";
            }
        }

        textView.setText(points);

        return true;
    }
}
0

There are 0 answers