Gestures in Android Wear

40 views Asked by At

I'd like to ask you about the gestures in android wear. There is some app (game 20x48), and playing that game player can swipe from one side to the other. And the problem is: when I swipe from left to right, the app is closing, because in android wear it's a custom gesture. So, my question is: how to disable that gesture in QtQuick App?

P.S: I tried to edit the Manifest, by adding some properties, including this one

<item name="android:windowSwipeToDismiss">false</item>

But it does not work. So, please, help me with this issue, thanks!

2

There are 2 answers

0
shahriar On

You can override the onBackPressed() method and modify it as you require.

0
Erik Nikoyan On

If anyone is interested, the problem was solved by overriding the gesture using the code below.

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                System.out.println("Start Swipe Right!!!!!!!!!!!!!!!!!!!!!!!!!");
                break;
            case MotionEvent.ACTION_MOVE:
                System.out.println("Swipe Right!!!!!!!!!!!!!!!!!!!!!!!!!");
                break;
            case MotionEvent.ACTION_UP:
                System.out.println("End Swipe Right!!!!!!!!!!!!!!!!!!!!!!!!!");
                break;
        }
        return super.onTouchEvent(event);
    }
    
    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_MOVE && event.getX() > 0) {
            System.out.println("Swipe Right Block!!!!!!!!!!!!!!!!!!!!!!!!!");
            return true;
        }
        return super.dispatchTouchEvent(event);
    }