Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Android中利用加速度计检测设备运动方向_Android - Fatal编程技术网

在Android中利用加速度计检测设备运动方向

在Android中利用加速度计检测设备运动方向,android,Android,使用SensorManager,我可以从加速计中找到x、y、z。 我可以检测到设备移动,但如何检查设备是否向下移动而不是向上移动 谢谢。该值将为负值 编辑:如果y向下移动,y的值将为负值。如果它向上移动,则为正(我接受它实际上可能是相反的方向,向上为负,向下为正,我还没有玩过android加速计,所以我将使用我使用过的其他加速计)

使用SensorManager,我可以从加速计中找到x、y、z。 我可以检测到设备移动,但如何检查设备是否向下移动而不是向上移动


谢谢。

该值将为负值

编辑:如果y向下移动,y的值将为负值。如果它向上移动,则为正(我接受它实际上可能是相反的方向,向上为负,向下为正,我还没有玩过android加速计,所以我将使用我使用过的其他加速计)