开发者

Resource leak when using KeyGuardManager

开发者 https://www.devze.com 2023-02-22 07:07 出处:网络
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:

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.

开发者_如何学Python

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消