I have a signal that puts my app to sleep for a given number of minutes (using AlarmManager) and then wakes it back up.
Everything is working except the screen doesn't ever come on. I'm using a wakelock like so from a BroadcastReceiver class:
KeyguardManager key = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
KeyguardLock lock = key.newKeyguardLock(TAG);
lock.disableKeyguard();
Log.v(TAG, "alarm: disabled keyguard.");
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
gpsMain.wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, TAG);
gpsMain.wl.acquire();
Log.v(TAG, "alarm: acquired wakelock");
Intent i = new Intent();
i.setAction(CUSTOM_INTENT);
context.sendBroadcast(i);
I then release the wakelock when I'm sure that my app is up and running and connected again. However, the screen never comes on! The app only actually comes back to life when I hit the power button to wake up the screen manually.
I'm developing on an HTC Hero. Any assistance would be GREATLY appreciated..
You need to use the ACQUIRE_CAUSES_WAKEUP
flag.
来源:https://stackoverflow.com/questions/3689878/wakelock-is-not-turning-on-the-screen-help