使用 KeyGuardManager 时发生资源泄漏
我正在尝试使用 KeyGuardManager 和 KeyguardLock 来解锁手机,但它仅在前几次有效,当我杀死我的应用程序时,我得到:
WindowManagerService.mKeyguardTokenWatcher:清理泄漏的引用
这个问题可能是相关的问题KeyGuardManager的问题,但我找不到提到的exitKeyguardSafely() 在 Android KeyguardManager API 参考中。我尝试使用 exitKeyguardSafely() 而不是 exitKeyguardSecurely() 但无济于事。
请帮忙!
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);
}
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);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来 KeygardLock 是一个信号量。确保调用reenableKeyguard()次数与disableKeyguard()次数相同,并且不会出现资源泄漏警告。
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.