Hey.
I'm developing an sms receiver, and i have included a KeyguardManager and a PowerManager to be able to disable the keyguard and turn on the screen if user would like to. This works great, but only once.
When a message is received, the keyguard gets unlocked and the screen is turned on, and it gives out a sound and vibration. But if i don't read the message right away, but let the device power off by screen time out, and i then receive another message while the last one is not read, the device does not turn the screen on again, and it does not give out a sound or vibration, until i turn on the screen manually, then the sound and vibration comes.
Why?
If i close all received messages, then my app is able to disable the keyguard and turn on the screen and give out a sound and vibration when a new message is received.
Here is my code that is run when the keyguard should be unlocked and the screen should be turned on.
I'm developing an sms receiver, and i have included a KeyguardManager and a PowerManager to be able to disable the keyguard and turn on the screen if user would like to. This works great, but only once.
When a message is received, the keyguard gets unlocked and the screen is turned on, and it gives out a sound and vibration. But if i don't read the message right away, but let the device power off by screen time out, and i then receive another message while the last one is not read, the device does not turn the screen on again, and it does not give out a sound or vibration, until i turn on the screen manually, then the sound and vibration comes.
Why?
If i close all received messages, then my app is able to disable the keyguard and turn on the screen and give out a sound and vibration when a new message is received.
Here is my code that is run when the keyguard should be unlocked and the screen should be turned on.
Code:
private void disableKeyGuard()
{
KeyguardManager km = (KeyguardManager)getSystemService(KEYGUARD_SERVICE);
kl = km.newKeyguardLock("SMSHandler");
kl.disableKeyguard();
km.exitKeyguardSecurely(null);
}
private void turnOnScreen()
{
PowerManager pm = (PowerManager)getSystemService(POWER_SERVICE);
wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP|PowerManager.SCREEN_DIM_WAKE_LOCK|PowerManager.ON_AFTER_RELEASE, "SMSHandler");
wl.acquire();
wl.release();
}