Android SmartWatch respond to a Long_Press Event

2019-09-01 05:23发布

I have my sonyericsson Smart Watch responding to Touch events quite nicely. Now I have to move on to other interactions. Is there a LONG_PRESS event implemented or do I just use the fact that there are several down events and one up?

An example of a SWIPE_EVENT would be welcome too.

1条回答
地球回转人心会变
2楼-- · 2019-09-01 05:55

The SmartWatch supports the control extensions by sending touch events and swipe events. For touch, you will e.g. get PRESS, RELEASE and LONGPRESS events along with the coordinates. So yes, TOUCH_ACTION_LONGPRESS is implemented. Example:

@Override
public void onTouch(final ControlTouchEvent event) {
    int action = event.getAction();
    switch(action) {
        case Control.Intents.TOUCH_ACTION_PRESS:
            // Do
            break;
        case Control.Intents.TOUCH_ACTION_RELEASE:
            // Do other
            break;
        case Control.Intents.TOUCH_ACTION_LONGPRESS:
            // Do more
            break;
        default:
            break;
    }
}

And for swipe, you will get the direction of the swipe.

@Override
public void onSwipe(int direction) {
    switch (direction) {
        case Control.Intents.SWIPE_DIRECTION_UP:
            break;
        case Control.Intents.SWIPE_DIRECTION_LEFT:
            break;
        case Control.Intents.SWIPE_DIRECTION_DOWN:
            break;
        case Control.Intents.SWIPE_DIRECTION_RIGHT:
            break;
        default:
            break;
    }
}

We just published two extensions as open source for your convenience: SmartWatch open source announcement. Especially the 8 game extension has some nice examples of what you are asking for, i.e. examples of touch and swipe.

And a link to the Smart Extension SDK.

Hope this helps!

查看更多
登录 后发表回答