Android Wear 5.1 wrist gesture API?

守給你的承諾、 提交于 2019-12-05 14:30:58

It seems a bit late but this looks like what you exactly wanted.

Although pushing, raising, shaking gesture is not available, flicking wrist out and in gesture is available.

Each wrist gesture is mapped to an int constant from the KeyEvent class, as shown in the following table:

Flick wrist out: KEYCODE_NAVIGATE_NEXT, This key code goes to the next item.

Flick wrist in: KEYCODE_NAVIGATE_PREVIOUS, This key code goes to the previous item.

You can handle the event like this: (example code from developer document)

public boolean onKeyDown(int keyCode, KeyEvent event) {
  switch (keyCode) {
   case KeyEvent.KEYCODE_NAVIGATE_NEXT:
    // Do something that advances a user View to the next item in an ordered list.
    return moveToNextItem();
   case KeyEvent.KEYCODE_NAVIGATE_PREVIOUS:
    // Do something that advances a user View to the previous item in an ordered list.
    return moveToPreviousItem();
  }
  // If you did not handle it, let it be handled by the next possible element as deemed by the Activity.
  return super.onKeyDown(keyCode, event);
 }

No, there is currently no wrist gesture API for Wear 1.0 devices and that is why the developer site does not mention wrist gestures.

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