Access accelerometer via Javascript in Android?

前端 未结 6 616
夕颜
夕颜 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:38

    If I'm reading the docs correctly, you could set up a class (within Java/Android) that provides the accelerometer functionality you need in public functions.

    Then setup a javascript interface for the webview using the addJavascriptInterface call, which makes the public functions in that class available to be called from within javascript.

提交回复
热议问题