如何检测android 设备旋转平行于地面?

How to detect android device rotation parallel to the ground?

据我所知,大多数 android 设备都允许通过加速度计检测旋转,但我注意到,它无法检测平行于地面的旋转。例如,如果我将设备放在 table 上并转动它,没有一个加速度计指示器不会改变。

图片上叫"alfa"旋转。那么如何检测这种转向呢?

要感测绕 z 轴的旋转,您需要实现罗盘功能。 this one. To make the resulting values more stable you need to implement some algorithm which smoothes your incoming data (averages over a queue of data, filtering outliers, etc.). Here is a good overview.

是一个很好的教程