简体   繁体   中英

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. 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?

You can check out the cordova accelerometer plugin (cordova-plugin-device-motion). you can add it to your cordova mobile project using

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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