Wakelock不打开屏幕上?帮帮我?帮帮我、屏幕上、Wakelock

2023-09-07 00:50:09 作者:用微笑掩盖了落寞

我有把我的应用程序睡分钟(使用AlarmManager)给定数量的信号,然后唤醒它回来了。

I have a signal that puts my app to sleep for a given number of minutes (using AlarmManager) and then wakes it back up.

一切工作,除了屏幕没有以往任何时候都来吧。我使用wakelock像这样从一个BroadcastReceiver类:

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);

我再放开wakelock时,我敢肯定,我的应用程序已经启动并运行,然后重新连接。但是,屏幕永远不会到来了!该应用程序实际上只回来生活,当我按下电源按钮手动唤醒屏幕。

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.

我开发上HTC Hero的。任何援助将不胜AP preciated ..

I'm developing on an HTC Hero. Any assistance would be GREATLY appreciated..

推荐答案

您需要使用的 ACQUIRE_CAUSES_WAKEUP 标志。

You need to use the ACQUIRE_CAUSES_WAKEUP flag.