My application has an alarm clock that starts after the period during which the phone went to sleep. I want the sliding lock to be redefined when an alarm is triggered, so that the current view immediately becomes visible. When the alarm goes off, the code starts (activates the camera), but the screen remains blank. If I press the power button and then slide the lock, the camera screen will appear. I call the following code to try to wake the device and show the screen, but it does not seem to make any difference. The last thing I tried was to add a call to userActivity, now I have run out of things to try to hope that someone has experience in how to do this.
public void setWakeLock(WakeLock wakeLock) {
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK |
PowerManager.ACQUIRE_CAUSES_WAKEUP, "MyWakeLock");
if ((wakeLock != null) &&
(wakeLock.isHeld() == false)){
wakeLock.acquire();
pm.userActivity(SystemClock.uptimeMillis(), true);
}
}
source
share