Android Xoom Accelerometer Accuracy Always Reliable

I am working on a simple compass type app for Android, testing Xoom WiFi. The accuracy of the accelerometer readings is always SensorManager.SENSOR_STATUS_UNRELIABLE . Magnetic field readings are always the accuracy of the SensorManager.SENSOR_STATUS_ACCURACY_HIGH . Could this be a bug in 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) {} }; 
+6
source share
3 answers

Nexus S also has this problem (with a gyroscope), and it looks like the lazy driver writer forgot to set the reading accuracy field;)

As long as the data is beautiful, it should be purely cosmetic.

+2
source

I donโ€™t know if you have problems with the accuracy of the compass, but I know what I did when I used

 magSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD) 

I highly recommend using something more like the following.

  mySensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE); List<Sensor> mySensors = mySensorManager.getSensorList(Sensor.TYPE_ORIENTATION); if(mySensors.size() > 0){ mySensorManager.registerListener(mySensorEventListener, mySensors.get(0), SensorManager.SENSOR_DELAY_NORMAL); sersorrunning = true; Toast.makeText(this, "Start ORIENTATION Sensor", Toast.LENGTH_LONG).show(); } 

I found that when I used a magnetic field sensor rather than an orientation sensor, it worked very well on my phone (Droid Incredible), but all kinds of crazy things on my wifeโ€™s phone (Droid Pro) and my colleagueโ€™s phone (Samsung Galaxy Tab). So you might consider replacing the sensor, just for device compatibility issues. :-)

+1
source

Source: https://habr.com/ru/post/887982/


All Articles