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.
开发者_如何学PythonPlease 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);
}
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.
精彩评论