Glass GDK:未调用onSensorChanged

时间:2014-07-15 12:24:06

标签: android google-glass google-gdk

我的活动是:

public class MyActivity extends Activity implements SensorEventListener, GestureDetector.BaseListener

我实现了函数

@Override
public boolean onGenericMotionEvent(MotionEvent event)
{
    Log.d("MOTION", "MOTION DETECTED");
}

@Override
public void onSensorChanged(SensorEvent event) {
    Log.d("MOTION", "SENSOR DETECTED");
}

onGenericMotionEvent工作正常,但onSensorChanged永远不会被调用,我错过了什么吗?

1 个答案:

答案 0 :(得分:1)

您是否在Activity内正确注册了SensorManager作为听众?你应该查看使用Glass上某些传感器的Compass样本。

您感兴趣的课程是OrientationManager

mSensorManager.registerListener(mSensorListener,
        mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR),
        SensorManager.SENSOR_DELAY_UI);