I have an activity with :
public class MyActivity extends Activity implements SensorEventListener, GestureDetector.BaseListener
I implement the functions
@Override
public boolean onGenericMotionEvent(MotionEvent event)
{
Log.d("MOTION", "MOTION DETECTED");
}
@Override
public void onSensorChanged(SensorEvent event) {
Log.d("MOTION", "SENSOR DETECTED");
}
onGenericMotionEvent works fine, but onSensorChanged is never called, am I missing something ?
Have you properly registered your Activity
as a listener within your SensorManager
? You should checkout the Compass
sample which makes use of some of the sensors on Glass.
The class you'd be interested in is the OrientationManager
:
mSensorManager.registerListener(mSensorListener,
mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR),
SensorManager.SENSOR_DELAY_UI);