Atul Bhardwaj Atul Bhardwaj - 4 months ago 18
Android Question

Android Vibrate Service (Vibrator) is not working for long time

I want to Vibrate a phone for long time(e.g 2 minutes) but It vibrates for very less time.
i am using this code

Vibrator mVibrate = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
mVibrate.vibrate(2*60*1000); // 2 Minutes


How to vibrate for 2 or 3 minutes ?

Answer

There is another way for long viabration as follows,

Vibrator mVibrate = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
long pattern[]={0,800,200,1200,300,2000,400,4000};
// 2nd argument is for repetition pass -1 if you do not want to repeat the Vibrate
mVibrate.vibrate(pattern,-1);

You can increase the pattern's array for long time viabration.