How to vibrate a phone in sync with a ringtone?

I want to vibrate my phone just like an incoming call synchronized with a ringtone. How do I achieve this?

+3
source share
1 answer
  • Get an MP3 library that gives you feedback for the magnitude of the sound (a bit like an equalizer in winamp)
  • Normalize this value to the scale [0.1]
  • Since the android api vibrator only supports the duration of the vibration (not the intensity), you need to sample this value to 0 or 1 (for some small durations).
  • If the sound is less than a certain value, 0.5, do not vibrate during this duration. Else vibrates.
+3

Source: https://habr.com/ru/post/1768998/


All Articles