Stay organized with collections
Save and categorize content based on your preferences.
KeyguardLock
open class KeyguardLock
Handle returned by KeyguardManager.newKeyguardLock
that allows you to temporarily disable / reenable the keyguard (lock screen).
Summary
Public methods |
open Unit |
Disable the keyguard from showing.
|
open Unit |
Reenable the keyguard.
|
Public methods
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# KeyguardManager.KeyguardLock\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 15](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nKeyguardLock\n============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/app/KeyguardManager.KeyguardLock \"View this page in Java\") \n\n```\nopen class KeyguardLock\n```\n\n|---|-----------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.app.KeyguardManager.KeyguardLock](#) |\n\n*** ** * ** ***\n\n| **This class was deprecated in API level 15.**\n|\n| Use [android.R.attr#showWhenLocked](../R.attr.html#showWhenLocked:kotlin.Int) or [android.app.Activity#setShowWhenLocked(boolean)](/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.\n\nHandle returned by [KeyguardManager.newKeyguardLock](/reference/kotlin/android/app/KeyguardManager#newKeyguardLock(kotlin.String)) that allows you to temporarily disable / reenable the keyguard (lock screen).\n\nSummary\n-------\n\n| Public methods ||\n|-----------------------------------------------------------------------------------|------------------------------------------------------------------------------|\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [disableKeyguard](#disableKeyguard())`()` Disable the keyguard from showing. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [reenableKeyguard](#reenableKeyguard())`()` Reenable the keyguard. |\n\nPublic methods\n--------------\n\n### disableKeyguard\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun disableKeyguard(): Unit\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nDisable the keyguard from showing. If the keyguard is currently showing, hide it. The keyguard will be prevented from showing again until [reenableKeyguard()](#reenableKeyguard()) is called.\n\nThis only works if the keyguard is not secure.\n\nA good place to call this is from [android.app.Activity#onResume()](/reference/kotlin/android/app/Activity#onResume()) \nRequires [android.Manifest.permission#DISABLE_KEYGUARD](../Manifest.permission.html#DISABLE_KEYGUARD:kotlin.String) \n**See Also**\n\n- [android.app.KeyguardManager#isKeyguardSecure()](/reference/kotlin/android/app/KeyguardManager#isKeyguardSecure())\n- \u003c#reenableKeyguard()\u003e \n\n### reenableKeyguard\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun reenableKeyguard(): Unit\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nReenable the keyguard. The keyguard will reappear if the previous call to [disableKeyguard()](#disableKeyguard()) caused it to be hidden. A good place to call this is from [android.app.Activity#onPause()](/reference/kotlin/android/app/Activity#onPause()) \nRequires [android.Manifest.permission#DISABLE_KEYGUARD](../Manifest.permission.html#DISABLE_KEYGUARD:kotlin.String) \n**See Also**\n\n- \u003c#disableKeyguard()\u003e"]]