Access accelerometer via Javascript in Android?

前端 未结 6 613
夕颜
夕颜 2020-12-02 23:51

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.

C

6条回答
  •  悲哀的现实
    2020-12-03 00:15

    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.

    Note - The W3C documentation title is named with 'device orientation', but the spec does indeed include 'devicemotion' event documentation.

提交回复
热议问题