我正在编写必须显示警告对话框的应用。唤醒我正在使用的设备:
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK |
PowerManager.ACQUIRE_CAUSES_WAKEUP, "AlertWindow");
wl.acquire(); // wake up the screen
//... show alert to user
Handler h = new Handler();
h.postDelayed(new Runnable() {
public void run() {
wl.release(); // release lock
}
}, TIME);
但问题是当警报窗口打开时,屏幕不会自动关闭。
警报显示之前 adb shell dumpsys power
:
mLocks.size=0:
演出后但尚未结束:
mLocks.size=1:
SCREEN_BRIGHT_WAKE_LOCK 'AlertWindow'ACQUIRE_CAUSES_WAKEUP activated (minState=3, uid=10070, pid=5183)
有没有办法使用处理程序关闭屏幕?关闭警报对话框后,锁定已关闭...