I have a service that checks for updates on my website and I would like it to be able to cause a vibration when a update is found even if the screen is off or locked.
The vibration currently only works if the screen is not off / locked. All other functions does work even if the screen is off / locked.
Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
long[] pattern = new long[]{0, 400, 200, 400};
if (Build.VERSION.SDK_INT >= 26) { // New API
vibrator.vibrate(VibrationEffect.createWaveform(pattern,0));
} else { // Old API
vibrator.vibrate(pattern, 0);
}
How can I vibrate a phone even if its screen is off? I've tried to use a WakeLock
but that doesn't seem to be the problem?
I have all the permissions set, as its working when the screen is on.
from How to Vibrate phone when the screen is off or locked via a background service?
No comments:
Post a Comment