简体   繁体   English

有没有一种方法可以检测Javascript / Cordova / HTML5中的设备振动?

[英]Is there a way to detect device vibration in Javascript/Cordova/HTML5?

I am working on a cordova app that makes use of the accelerator data. 我正在使用可利用加速器数据的cordova应用程序。 But I need the app to be aware of acceleration originating due to phone vibration, in order to account for it. 但是我需要应用程序注意由于手机振动而产生的加速度,以便加以考虑。

I understand that there exists support to create vibrations in HTML5 via the vibration API, but is there a way to fire/listen to events corresponding to vibration triggered by some other application or the OS? 我了解存在通过振动API在HTML5中创建振动的支持,但是有没有办法触发/监听与某些其他应用程序或操作系统触发的振动相对应的事件?

You can check out the cordova accelerometer plugin (cordova-plugin-device-motion). 您可以签出cordova加速度计插件(cordova-plugin-device-motion)。 you can add it to your cordova mobile project using 您可以使用将其添加到您的cordova移动项目中

cordova plugin add cordova-plugin-device-motion You can find out more from [here]: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-device-motion/ cordova plugin add cordova-plugin-device-motion您可以在[here]中找到更多信息: https : //cordova.apache.org/docs/en/latest/reference/cordova-plugin-device-motion/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM