android.permission.DISABLE_KEYGUARD

disable key lock

Allows an application to disable the key lock and any associated password security. A legitimate example of this is the phone disabling the key lock when receiving an incoming phone call, then re-enabling the key lock when the call is finished.

Protection level: normal

Usage in AndroidManifest.xml:

1
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"></uses-permission>

KeyguardManager.KeyguardLock

This class was deprecated in API level 13.
Use FLAG_DISMISS_KEYGUARD and/or FLAG_SHOW_WHEN_LOCKED instead; this allows you to seamlessly hide 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 newKeyguardLock(String) that allows you to disable / reenable the keyguar

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

Sample usage:

1
2
3
KeyguardManager keyguardManager = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE);
KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
lock.disableKeyguard();

1
2
3
KeyguardManager keyguardManager = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE);
KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
lock.reenableKeyguard();