How to vibrate the phone in sync with the ringtone?
Question
I want to vibrate the phone in the same way as the incoming call in sync with the ringtone. How do I achieve it?
Solution
- Get an MP3 library that gives you feedback for magnitude of sound (Something like equalizer in winamp)
- Normalize this magnitude to a scale of [0,1]
- As the android vibrator api supports only vibration duration (not intensity) you need to discretize this magnitude to either 0 or 1 (for some small duration).
- If the magnitude of sound is less than some value, 0.5, do not vibrate for that duration. Else vibrate.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow