Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Wear 5.1 wrist gesture API?

Android 5.1.1 for wearables introduced the ability to dimiss notifications by rotating/flicking your wrist. Is this API exposed for developers to use? I'm unable to find any information on this, and their wearables developer site does not seem to have been updated.

like image 722
Tom Avatar asked Feb 10 '23 18:02

Tom


2 Answers

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.

like image 83
ianhanniballake Avatar answered Feb 12 '23 09:02

ianhanniballake


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);
 }
like image 30
Alfred Woo Avatar answered Feb 12 '23 08:02

Alfred Woo