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.