nufront 新岸线android 4.03重力感应方向反了,重力感应方向修改

来源:互联网 发布:单片机时钟电路设计 编辑:程序博客网 时间:2024/04/29 21:06

android\frameworks\base\core\java\android\view\WindowOrientationListener.java

onsensorchanged 方法里面 x y z 轴值控制翻转方向。

 

  public void onSensorChanged(SensorEvent event) {
            final boolean log = mOrientationListener.mLogEnabled;

            // The vector given in the SensorEvent points straight up (towards the sky) under ideal
            // conditions (the phone is not accelerating).  I'll call this up vector elsewhere.
            float x = -event.originalValues[ACCELEROMETER_DATA_X];  //change by capeng 负 正负刚好是相反的方向
            float y = -event.originalValues[ACCELEROMETER_DATA_Y];   //change by capeng 负 正负刚好是相反的方向
            float z = -event.originalValues[ACCELEROMETER_DATA_Z];   //change by capeng 负 正负刚好是相反的方向