【问题标题】:getting device orientation in honeycomb在蜂窝中获取设备方向
【发布时间】:2011-08-26 18:13:42
【问题描述】:

SensorManager.getRotationMatrix(...) 函数在 Android 3.0+ 中不起作用。我已经在运行 android 2.x 的各种手机/平板电脑上运行了以下代码,并且运行良好。

public void onSensorChanged(SensorEvent event) {
    float[] magnetic = event.values;

    if( accelerometer != null ) {
        float[] array = new float[9];

        SensorManager.getRotationMatrix(array, null, accelerometer, magnetic);

        // in 3.0+, 'array' contains all 0's here, which is bad

        SensorManager.getOrientation(array, orientation);
    }
}

【问题讨论】:

    标签: android matrix rotation sensors


    【解决方案1】:

    事实证明,磁[0] 包含一个介于 0 和 360 之间的数字,包含方位角。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-14
      • 2012-03-20
      • 2023-03-10
      • 1970-01-01
      • 2013-05-10
      • 2017-04-01
      • 1970-01-01
      相关资源
      最近更新 更多