从android加速度计获取倾斜角度 [英] Get tilt angle from the android accelerometer

查看:600
本文介绍了从android加速度计获取倾斜角度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个实现 SensorEventListener 的类,我想获得
倾斜角我的设备使用加速度计

I have a class that implements SensorEventListener and I would like to get the tilt Angle of my device using the Accelerometer.

我在互联网上寻找示例,但是他们使用
Sensor.TYPE_MAGNETIC_FIELD

I looked for examples on the internet but they use Sensor.TYPE_MAGNETIC_FIELD.

我相信我的设备没有此传感器,因为当我在检查后执行


manager .getSensorList(Sensor.TYPE_ACCELEROMETER).size(),我得到

I believe my device doesn't have this sensor because when I do the following check
manager.getSensorList(Sensor.TYPE_ACCELEROMETER).size(), I get zero.

有没有办法只需使用
Sensor.TYPE_ACCELEROMETER 值获得倾斜角

Is there a way to get the tilt Angle by just using Sensor.TYPE_ACCELEROMETER values?

推荐答案

正如人们所建议的,您可以使用加速度计和磁性传感器来做到这一点。

As people suggested you can use the accelerometer and magnetic sensor to do this.

这是一个具有完整解决方案的博客文章。

Here is a blog post with a complete solution.

http://www.ahotbrew.com/how-to-detect-forward-and-backward-tilt/

这篇关于从android加速度计获取倾斜角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆