简体   繁体   中英

Wakelock is not turning on the screen? Help?

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..

您需要使用ACQUIRE_CAUSES_WAKEUP标志。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM