Atul Bhardwaj
Atul Bhardwaj

Reputation: 6707

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 ?

Upvotes: 2

Views: 1973

Answers (1)

Lucifer
Lucifer

Reputation: 29642

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.

Upvotes: 2

Related Questions