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.
how to detect head movement via glass gdk api?
-
01-10-2022 - |
Pregunta
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;
}
})
Solución
Otros consejos
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
}
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow