问题描述
有没有办法在Android的浏览器上使用Javascript访问加速度计数据?我知道它支持onorientationchange,但我想得到所有东西。
Is there any way to access accelerometer data using Javascript on Android's browser? I know it supports "onorientationchange", but I'd like to get everything.
澄清:我问的是如何在网站上做到这一点,而不是原生应用。
Clarification: I'm asking how to do this in a website, not a native app.
推荐答案
从ICS,Android 4.0开始,您可以通过JavaScript事件监听器使用'devicemotion'事件来访问加速度计数据。请参阅W3C文档,了解如何访问它 - 。
As of ICS, Android 4.0, you can use the 'devicemotion' event via a JavaScript event listener to access the accelerometer data. See the W3C documentation on how to access it - http://dev.w3.org/geo/api/spec-source-orientation.html.
注 - W3C文档标题以设备方向命名,但规范确实包括' devicemotion'事件文档。
Note - The W3C documentation title is named with 'device orientation', but the spec does indeed include 'devicemotion' event documentation.
这篇关于通过Android中的Javascript访问加速度计?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!