Question

I wrote some code that mute the phone whenever an incoming call is received. When the phone in vibrate mode I use the following code to stop the phone vibration:

Vibrator vib = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
vib.cancel();

While it worked on my Nexus One with android 2.1, it seems that it doesn't stop the vibration on an HTC Desire handset with android 2.1. Have someone encountered this issue?

Doron

Was it helpful?

Solution 2

It seems that the vibration doesn’t stop since the stop vibration code which is attached to an incoming call broadcast receiver is executed in some cases before the vibration start and therefore it seems that the vibration doesn't stop.

The solution for me was to check whether the phone vibrates and if so to turn the vibration off else to turn the vibration mode setting to off which prevent the vibration to start.

OTHER TIPS

That's one of the cons with Android, different devices behave differently. Have you tried using vibrate(3000); which is equivalent to let the device vibrate for 3 seconds, insted of trying to cancel a started service?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top