Wakelock is not turning on the screen? Help?

纵饮孤独 提交于 2019-12-01 10:13:06

问题


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


回答1:


You need to use the ACQUIRE_CAUSES_WAKEUP flag.



来源:https://stackoverflow.com/questions/3689878/wakelock-is-not-turning-on-the-screen-help

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!