我正在尝试使用KeyGuardManager和KeyguardLock来解锁手机,但是它只能在头几次使用,并且当我杀死我的应用程序时,我得到:WindowManagerService.mKeyguardTokenWatcher: cleaning up leaked reference
此问题可能与问题problem with KeyGuardManager有关,但在Android KeyguardManager API reference中找不到提到的exitKeyguardSafely()。我尝试使用exitKeyguardSecurely()代替exitKeyguardSafely()无济于事。
请帮忙!
private final String LOG_TAG = getClass().getSimpleName();
private void unlock() {
KeyguardManager keyguardManager = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE);
KeyguardLock lock = keyguardManager.newKeyguardLock(LOG_TAG);
lock.disableKeyguard();
keyguardManager.exitKeyguardSecurely(null);
}
最佳答案
似乎KeygardLock是一个信号量。确保调用reenableKeyguard()的次数与disableKeyguard()相同,并且没有资源泄漏的警告。