我注意到我无法解释的 Android 非常有趣的行为。我正在使用以下代码唤醒手机并禁用键盘保护:
PowerManager.WakeLock mFullWakelock = mPowerManager.newWakeLock(
(PowerManager.SCREEN_BRIGHT_WAKE_LOCK |
PowerManager.FULL_WAKE_LOCK |
PowerManager.ACQUIRE_CAUSES_WAKEUP),
LOCK_TAG
);
mFullWakelock.acquire();
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock(LOCK_TAG);
keyguardLock.disableKeyguard();
想象一下唤醒(以编程方式)->禁用键盘保护(以编程方式)->按电源按钮(手动)->唤醒->禁用键盘保护的循环。这个循环很好,直到我在手机的键盘保护被禁用时手动按下主页按钮。之后,手机确实会唤醒,但键盘保护不再以编程方式禁用。我会很感激任何想法!