Android 浏览器震动检测与 JavaScript 的 Web 应用程序
任何版本的 Android Web 浏览器都可以检测 javascript shake 事件吗?像这样的事情:window.addEventListener('devicemotion', this, false);
我似乎找不到任何相关信息。
我正在使用 WKShake,此处引用:Javascript。监听 iPhone 震动事件吗?
我想知道这是否也适用于 Android。
Do any versions of androids web browser detect javascript shake events? Something like this:window.addEventListener('devicemotion', this, false);
I can't seem to find any information on this.
I am using WKShake which is refrenced here: Javascript. Listen for iPhone shake event?
and am wondering if this is going to work on android as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
经过一些研究,我发现 Android 浏览器无法访问加速度计数据。也许在未来的某个时候他们将允许浏览器访问这些数据。
After some research, I have discovered that the android browser does not have access to accelerometer data. Perhaps some time in the future they will allow the browser to access this data.
Shake.js (http://functionn.blogspot.com/2012/03/shakejs-custom-shake-event-javascript.html) 是一个自定义“摇动”事件 JavaScript 插件,适用于使用设备加速计的移动 Web 浏览器。您的网络浏览器必须支持 devicemotion 事件才能使该插件正常工作。 Shake.js 使用内置功能检测来确定它是否可以在您的 Web 浏览器中运行。它将在不支持的浏览器上静默终止。
Shake.js (http://functionn.blogspot.com/2012/03/shakejs-custom-shake-event-javascript.html) is a custom 'shake' event JavaScript plugin for mobile web browsers using device accelerometer. Your web browser must support the devicemotion event for this plugin to work. Shake.js uses built-in feature detection to determine if it can run in your web browser. It will terminate silently on non-supporting browsers.
以下是基于 PhoneGap 加速计 API 构建的 Android JavaScript shake 方法的实现 - github链接
Here's an implementation of a JavaScript shake method for Android built on top of PhoneGap's accelerometer API - github link