# KeyguardManager.KeyguardLock

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Deprecated in[API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# KeyguardLock

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/app/KeyguardManager.KeyguardLock "View this page in Java")  

```
open class KeyguardLock
```

|---|--------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                       ||
| ↳ | [android.app.KeyguardManager.KeyguardLock](https://developer.android.com/reference/kotlin/android/app/KeyguardManager.KeyguardLock#) |

*** ** * ** ***

| **This class was deprecated in API level 15.**
|
| Use[android.R.attr#showWhenLocked](https://developer.android.com/reference/kotlin/android/R.attr.html#showWhenLocked:kotlin.Int)or[android.app.Activity#setShowWhenLocked(boolean)](https://developer.android.com/reference/kotlin/android/app/Activity#setShowWhenLocked(kotlin.Boolean))instead. This allows you to seamlessly occlude and unocclude the keyguard as your application moves in and out of the foreground and does not require that any special permissions be requested.

Handle returned by[KeyguardManager.newKeyguardLock](https://developer.android.com/reference/kotlin/android/app/KeyguardManager#newKeyguardLock(kotlin.String))that allows you to temporarily disable / reenable the keyguard (lock screen).

## Summary

|                                                                                                                    Public methods                                                                                                                     ||
|----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [disableKeyguard](https://developer.android.com/reference/kotlin/android/app/KeyguardManager.KeyguardLock#disableKeyguard())`()` Disable the keyguard from showing. |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [reenableKeyguard](https://developer.android.com/reference/kotlin/android/app/KeyguardManager.KeyguardLock#reenableKeyguard())`()` Reenable the keyguard.           |

## Public methods

### disableKeyguard

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun disableKeyguard(): Unit
```

**Deprecated:** *Deprecated in Java.*

Disable the keyguard from showing. If the keyguard is currently showing, hide it. The keyguard will be prevented from showing again until[reenableKeyguard()](https://developer.android.com/reference/kotlin/android/app/KeyguardManager.KeyguardLock#reenableKeyguard())is called.

This only works if the keyguard is not secure.

A good place to call this is from[android.app.Activity#onResume()](https://developer.android.com/reference/kotlin/android/app/Activity#onResume())  
Requires[android.Manifest.permission#DISABLE_KEYGUARD](https://developer.android.com/reference/kotlin/android/Manifest.permission.html#DISABLE_KEYGUARD:kotlin.String)  
**See Also**

- [android.app.KeyguardManager#isKeyguardSecure()](https://developer.android.com/reference/kotlin/android/app/KeyguardManager#isKeyguardSecure())
- <https://developer.android.com/reference/kotlin/android/app/KeyguardManager.KeyguardLock#reenableKeyguard()>  

### reenableKeyguard

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun reenableKeyguard(): Unit
```

**Deprecated:** *Deprecated in Java.*

Reenable the keyguard. The keyguard will reappear if the previous call to[disableKeyguard()](https://developer.android.com/reference/kotlin/android/app/KeyguardManager.KeyguardLock#disableKeyguard())caused it to be hidden. A good place to call this is from[android.app.Activity#onPause()](https://developer.android.com/reference/kotlin/android/app/Activity#onPause())  
Requires[android.Manifest.permission#DISABLE_KEYGUARD](https://developer.android.com/reference/kotlin/android/Manifest.permission.html#DISABLE_KEYGUARD:kotlin.String)  
**See Also**

- <https://developer.android.com/reference/kotlin/android/app/KeyguardManager.KeyguardLock#disableKeyguard()>