2

I am trying to use the KeyGuardManager and KeyguardLock to unlock the phone but it only works the first few times and when I kill my application I get:

WindowManagerService.mKeyguardTokenWatcher: cleaning up leaked reference

This problem is probably related to the issue problem with KeyGuardManager but I can not find the mentioned exitKeyguardSafely() in the Android KeyguardManager API reference. Instead of exitKeyguardSafely() i tried using exitKeyguardSecurely() to no avail.

Please help!

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

1 Answer 1

2

Seems that the KeygardLock is a semaphore. Make sure to call reenableKeyguard() as many times as disableKeyguard() and there is no warning of resource leak.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.