Tom Tom - 1 year ago 110
Android Question

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.

Answer Source

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) {
    // Do something that advances a user View to the next item in an ordered list.
    return moveToNextItem();
    // 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);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download