android - Android 中的传感器坐标系不会改变,对吗?

标签 android android-sensors tilt-sensor

我读过很多地方,例如:One Screen Deserves Another那:“API 使用的用于设备自然方向的传感器坐标系不会随着设备移动而改变,并且与 OpenGL 坐标系相同。”

现在,我得到与这张图片相同的读数:enter image description here

我不明白的是:如果我旋转手机(屏幕始终面向用户)时坐标系没有改变,则重力应施加在 Y 轴上, 总是。只有当我将手机放在屏幕不再面向用户的位置(例如放在 table 上,重力应施加在 Z 轴上)时,它才应该改变轴。

我的理解有什么问题吗?

谢谢!吉列尔莫。

最佳答案

当设备的屏幕方向改变时,轴会交换。根据您引用的文章:

However, the Android sensor APIs define the sensor coordinate space to be relative to the top and side of the device — not the short and long sides. When the system reorients the screen in response to holding the phone sideways, the sensor coordinate system no longer lines up with the screen’s coordinate system, and you get unexpected rotations in the display of your app.

如果您愿意,要访问未交换的值,请在 values[] 中使用索引 3、4 和 5,否则同一篇文章中提到的一些建议非常有效!

关于android - Android 中的传感器坐标系不会改变,对吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9293183/

相关文章:

安卓跌倒检测

android - 如何以稳定准确的方式读取Android加速度计值?

android - 解析.com : Can we prevent android from creating new installation records when an updated app is installed?

java - GdxRuntimeException : File not found

android - 构建Android : No Rule to make target

c - 使用俯仰和横滚值的倾斜传感器的图形设计

android - 如何检测安装了加速度计的安卓设备的左右倾斜?

java - 从另一个类调用 Internet Detect 无效

用于加速度计变换的Android旋转矩阵

android - 是否可以在我的应用程序中从 Androidwatch 获取心率更新?