In my application, I am starting the VIBRATOR_SERVICE through the following code
long[] pattern = {50,100,1000}
Vibrator vibe=(Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
vibe.vibrate(pattern, 0);
I want the vibration continue till I call
vibe.cancel();
The Code is working fine, but the vibration getting off when the screen goes to sleep mode.
I want the vibration continue even after the screen goes to sleep mode. Is there any ways to do this? Please help me.
Thanks in advance. 🙂
The correct answer to the question is as follows
Before doing this, don’t forget to add the permission “
android.permission.VIBRATE” to your app manifest file.wakelock will not work here, because the receiver will receive the intent only after the screen goes off. Though we can acquire the wakelock after the screen goes to off mode the vibration stops, because it happens with the
ACTION_SCREEN_OFF. So it can be done by starting the vibration again after receiving the broadcast.