Вопрос

I write an app for google glass platform using the gdk.

how can I detect and react to head movement?

I don't find the proper listener not the Gesture enum (e.g. Gesture.SWIPE_UP)

gestureDetector.setBaseListener(new GestureDetector.BaseListener() {
  @Override
  public boolean onGesture(Gesture gesture) {
    if (gesture == Gesture.TAP) {
        //do something
      }
      return true;
    } else if (gesture == Gesture.SWIPE_UP) {


gestureDetector.setScrollListener(new ScrollListener() {

    @Override
    public boolean onScroll(float arg0, float arg1, float arg2) {
        // TODO Auto-generated method stub
        return false;
    }
})
Это было полезно?

Решение

Take a look here: https://developers.google.com/glass/develop/gdk/location-sensors . It should help you out with the accelerator and other sensors that are accessible via the GDK. The code you have copied is for the touch pad, not for head movement.

Другие советы

take a look at this repo:

https://github.com/thorikawa/glass-head-gesture-detector

Usage: public class MainActivity extends Activity implements OnHeadGestureListener {

private HeadGestureDetector mHeadGestureDetector;

@Override
protected void onCreate(Bundle savedInstanceState) {
    …
    mHeadGestureDetector = new HeadGestureDetector(this);
    mHeadGestureDetector.setOnHeadGestureListener(this);
    …
}

@Override
protected void onResume() {
    …
    mHeadGestureDetector.start();
}

@Override
protected void onPause() {
    …
    mHeadGestureDetector.stop();
}

@Override
public void onNod() {
    // Do something
}

@Override
public void onShakeToLeft() {
    // Do something
}

@Override
public void onShakeToRight() {
    // Do something
}

}

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top