Android SmartWatch respond to a Long_Press Event

落花浮王杯 提交于 2019-12-12 04:13:51

问题


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:


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!



来源:https://stackoverflow.com/questions/10487819/android-smartwatch-respond-to-a-long-press-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!