views:

56

answers:

2

Hi all,

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

A: 

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?

BennySkogberg
@BennySkogberg - then what about when we implement "Pattern-Vibrate"such as long[] pattern = {0L,100L,250L,1000L,250L,500L}; vibrator.vibrate(pattern,2);so "Cancel" should be there to stop vibrating
PM - Paresh Mayani
I agree, but if cancel() doesn't work on HTC Desire - then what else can you do?Also found out that this issue isn't new to the device: http://forum.xda-developers.com/showthread.php?t=661702
BennySkogberg
Benny, Thanks for the answer. I need the phone to stop vibrating on an incoming call.How does make it vibrate for 3 secs helps me?
DoronBM
A: 

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.

DoronBM