概述
Sensor.TYPE_ORIENTATION 常数在 API 8 中已弃用,官方推荐使用 SensorManager.getOrientation()
替代。关于 Orientation Sensor(被弃用的方向传感器) 在官方文档中的概述里有这样一句话:
The orientation sensor is software-based and derives its data from the accelerometer and the geomagnetic field sensor. (方向传感器是基于软件的,并且它的数据是通过加速度传感器和磁场传感器共同获得的)
上面的描述其实少了一个重要角色,即 SensorManager.getOrientation()
。方向传感器 在被弃用之前,正是通过 SensorManager.getOrientation()
来借助 加速度传感器(Sensor.TYPE_ACCELEROMETER) 和 地磁场传感器(TYPE_MAGNETIC_FIELD) 的数据得到的。
<