简体   繁体   English

使用disableKeyguard和reenableKeyguard进行锁定和解锁

[英]Using disableKeyguard and reenableKeyguard to lock and unlock

In my application I am using disableKeyguard and reenableKeyguard to lock and unlock a screen with proximity and accelerometer sensors respectively. 在我的应用程序中,我正在使用disableKeyguard和reenableKeyguard分别通过接近和加速度传感器锁定和解锁屏幕。 My application working with some bugs. 我的应用程序正在处理一些错误。 If user unlocks a screen by dragging (without using my app) then my application will not lock !. 如果用户通过拖动(而不使用我的应用程序) unlocks屏幕,则我的应用程序将不会lock !。 How to prevent this issue? 如何预防这个问题? How to fix this bug? 如何解决这个错误? plz help me. 请帮助我。

Is there any other way to lock and unlock ? 还有其他方法可以锁定和解锁吗?

thanks in advance. 提前致谢。

reenableKeyguard reenableKeyguard

void reenableKeyguard() Reenable the keyguard. reenableKeyguard()void重新启用键盘保护。 The keyguard will reappear if the previous call to disableKeyguard() caused it to be hidden. 如果先前对disableKeyguard()的调用导致隐藏,则键盘保护将重新出现。 A good place to call this is from onPause() Note: This call has no effect while any DevicePolicyManager is enabled that requires a password. 从onPause()调用它是一个好地方。注意:当启用任何需要密码的DevicePolicyManager时,此调用无效。

This method requires the caller to hold the permission DISABLE_KEYGUARD. 此方法要求调用方持有权限DISABLE_KEYGUARD。

Your app has to be the one to call disableKeyguard() first, else you cannot lock it using reenableKeyguard() 您的应用是一个叫disableKeyguard()第一,否则你无法使用锁定reenableKeyguard()

Source: https://developer.android.com/reference/android/app/KeyguardManager.KeyguardLock.html 来源: https : //developer.android.com/reference/android/app/KeyguardManager.KeyguardLock.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM