android - 如何获得android设备旋转
解决方案
您可以通过以下方式获得 Azimuth、Pitch 和 Roll:
private SensorManager sensorManager;
...
// Rotation matrix based on current readings from accelerometer and magnetometer.
final float[] rotationMatrix = new float[9];
SensorManager.getRotationMatrix(rotationMatrix, null,
accelerometerReading, magnetometerReading);
// Express the updated rotation matrix as three orientation angles.
final float[] orientationAngles = new float[3];
SensorManager.getOrientation(rotationMatrix, orientationAngles);
来源https://developer.android.com/guide/topics/sensors/sensors_position#java
推荐阅读
- php - Laravel API 返回文件并且客户端必须显示下载对话框
- javascript - 在页面上找不到我的 jQuery?它是否在其他元素后面显示加载的数据?
- azure-devops - Azure Devops Pipeline 测试步骤失败 - 数据文件的路径不正确
- asp.net - 在 ActionFilterAttribute 中添加标题
- python-2.7 - Python鼻子测试覆盖包并排除一些目录
- javascript - 如何使用 setInterval 函数在屏幕上显示的每个值之间以 500 毫秒的间隔显示阶乘计算?
- javascript - 在每个单元格上动态添加两个不同的按钮
- kendo-ui - Kendo Grid 中的动态过滤器
- c# - 如何在 C# 中追加和更新 cookie?
- selenium - 元素在 chrome 中不可点击