本文介绍了Android的Xoom的accelererometer准确性永远是靠不住的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Android一个简单的指南针类型的应用程序,在测试Xoom的无线网络。加速度计读数的准确性总是 SensorManager.SENSOR_STATUS_UNRELIABLE 。磁场读数总是精度 SensorManager.SENSOR_STATUS_ACCURACY_HIGH 。难道这是在Xoom的一个bug,还是有一个问题在我的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);私人最终SensorEventListener accelListener =新SensorEventListener(){
  公共无效onSensorChanged(SensorEvent事件){
    Log.d(TAG,加(+ event.values​​ [0] +,+ event.values​​ [1] +,+ event.values​​ [2] +)的精度=+ accuracyTag(事件。准确性));
  }
  公共无效onAccuracyChanged(传感器传感器,精度INT){}
};


解决方案

它看起来像在XOOM的bug。检查这些帖子:

http://community.developer.motorola.com/t5/Android-App-Development-for/Xoom-magnetometer-Y-axis-always-reads-zero/td-p/14184

http://community.developer.motorola.com/t5/Android-App-Development-for/Q-Compass-Behavior-when-Xoom-is-held-in-different-orientations/td-p/14332

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) {}
};
解决方案

It looks like a bug in the xoom. Check these posts:

http://community.developer.motorola.com/t5/Android-App-Development-for/Xoom-magnetometer-Y-axis-always-reads-zero/td-p/14184

http://community.developer.motorola.com/t5/Android-App-Development-for/Q-Compass-Behavior-when-Xoom-is-held-in-different-orientations/td-p/14332

这篇关于Android的Xoom的accelererometer准确性永远是靠不住的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 19:25