I wan to start Vibrate When Locked Screen. My Screen is open/working when wake lock. My Question is that Vibrate is not working when Screen Locked Mode. if Device Locked is open then working.
onCreate()
KeyguardManager myKM = (KeyguardManager) getApplicationContext().getSystemService(Context.KEYGUARD_SERVICE);
if( myKM.inKeyguardRestrictedInputMode()) {
//it is locked
Log.e("Incomimg","Device Locked");
onStartVibrate();
} else {
//it is not locked
Log.e("Incomimg","Device Not Locked");
}
See Below Methods are for Vibrate on/off
public void onStartVibrate()
{
long[] pattern = {500, 250, 0 ,100,0, 250, 500};
vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(pattern,0);
}
public void onStopVibrate(){
try{
vibrator.cancel();
}catch (Exception ex)
{
}
}