唤醒锁未打开屏幕?帮助?
我有一个信号让我的应用程序休眠指定的分钟数(使用 AlarmManager),然后将其唤醒。
一切正常,只是屏幕不亮。我正在使用 BroadcastReceiver 类中的唤醒锁:
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);
然后,当我确定我的应用程序已启动并运行并再次连接时,我会释放唤醒锁。但是,屏幕永远不会亮起!只有当我按下电源按钮手动唤醒屏幕时,该应用程序才会真正恢复活力。
我正在 HTC Hero 上进行开发。任何帮助将不胜感激..
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..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用
ACQUIRE_CAUSES_WAKEUP
旗帜。You need to use the
ACQUIRE_CAUSES_WAKEUP
flag.