I'm working on a simple compass type application for Android, testing on Xoom WiFi. The accuracy of the accelerometer readings is always SensorManager.SENSOR_STATUS_UNRELIABLE
. The magnetic field readings are always accuracy SensorManager.SENSOR_STATUS_ACCURACY_HIGH
. Could this be a bug in the Xoom, or is there a problem in my code?
onCreate:
mSensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
accelGravitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
magSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
onResume:
mSensorManager.registerListener(accelListener, accelGravitySensor, SensorManager.SENSOR_DELAY_NORMAL);
mSensorManager.registerListener(magListener, magSensor, SensorManager.SENSOR_DELAY_NORMAL);
private final SensorEventListener accelListener = new SensorEventListener() {
public void onSensorChanged(SensorEvent event) {
Log.d(TAG, "accel (" + event.values[0] + ", " + event.values[1] + ", " + event.values[2] + ") accuracy=" + accuracyTag(event.accuracy));
}
public void onAccuracyChanged(Sensor sensor, int accuracy) {}
};