문제

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