How to capture the onSwipeDown event on google glass using a native app?
android, android-gesture, google-glass
Solution
Here is the (weird) solution.
It seems that the swipeDown gesture is not really a gesture but more a button click.
That means that you should use the callback methods of your activity to capture these events.
private static final int KEY_SWIPE_DOWN = 4;
@Override
public boolean onKeyUp(int keyCode, KeyEvent event)
{
if (keyCode == KEY_SWIPE_DOWN)
{
// there was a swipe down event
return true;
}
return false;
}
I think you do not need to care about the onKeyDown() callback because this callback is only triggered directly before the onKeyUp() event and not when you are beginning the gesture.
Problem
I was able to capture most of the events triggered by the touchpad of a google glass using the SimpleOnGestureListener in a native app. With the following code you can capture these events MainActivity.java: ``` private GestureDetector gestureDetector; @Override protected void onCreate(Bundle savedInstanceState) { gestureDetector = new GestureDetector(this, new MyGestureListener()); } @Override public boolean onGenericMotionEvent(MotionEvent event) { gestureDetector.onTouchEvent(event); return true; } ``` MyGestureListener: ``` public class MyGestureListener extends android.view.GestureDetector.SimpleOnGestureListener { @Override public boolean onFling(MotionEvent start, MotionEvent finish, float velocityX, float velocityY) { // check for velocity direction to identify swipe forward / backward / up and down return true; } } ``` I found two different sources for gesture processing I tried: - Capture Glass D-Pad events in Android - Capturing Gesture Controls for Use in Native Android Glass Apps But with none of them I was able to catch the swipeDown event. The callback onFling() is only called on "swipe forward", "swipe backward" and "swipe up" but never called when I do a "swipe down". Any hints or have you already managed to catch the swipe down? I am really clueless here.