public class KeyguardManager extends Object
Context.getSystemService(java.lang.String)
with argument Context.KEYGUARD_SERVICE
. The
actual class to control the keyboard locking is
KeyguardManager.KeyguardLock
.Modifier and Type | Class and Description |
---|---|
class |
KeyguardManager.KeyguardLock
Deprecated.
Use
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
and/or WindowManager.LayoutParams.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(java.lang.String) that allows
you to disable / reenable the keyguard. |
static interface |
KeyguardManager.OnKeyguardExitResult
Callback passed to
exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult) to notify
caller of result. |
Modifier and Type | Field and Description |
---|---|
static String |
ACTION_CONFIRM_DEVICE_CREDENTIAL
Intent used to prompt user for device credentials.
|
static String |
ACTION_CONFIRM_DEVICE_CREDENTIAL_WITH_USER
Intent used to prompt user for device credentials.
|
static String |
EXTRA_DESCRIPTION
A CharSequence description to show to the user when used with
ACTION_CONFIRM_DEVICE_CREDENTIAL . |
static String |
EXTRA_TITLE
A CharSequence dialog title to show to the user when used with a
ACTION_CONFIRM_DEVICE_CREDENTIAL . |
Modifier and Type | Method and Description |
---|---|
Intent |
createConfirmDeviceCredentialIntent(CharSequence title,
CharSequence description)
Get an intent to prompt the user to confirm credentials (pin, pattern or password)
for the current user of the device.
|
Intent |
createConfirmDeviceCredentialIntent(CharSequence title,
CharSequence description,
int userId)
Get an intent to prompt the user to confirm credentials (pin, pattern or password)
for the given user.
|
void |
exitKeyguardSecurely(KeyguardManager.OnKeyguardExitResult callback)
Deprecated.
Use
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
and/or WindowManager.LayoutParams.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.
Exit the keyguard securely. The use case for this api is that, after
disabling the keyguard, your app, which was granted permission to
disable the keyguard and show a limited amount of information deemed
safe without the user getting past the keyguard, needs to navigate to
something that is not safe to view without getting past the keyguard.
This will, if the keyguard is secure, bring up the unlock screen of
the keyguard.
This method requires the caller to hold the permission
|
boolean |
inKeyguardRestrictedInputMode()
If keyguard screen is showing or in restricted key input mode (i.e. in
keyguard password emergency screen).
|
boolean |
isDeviceLocked()
Returns whether the device is currently locked and requires a PIN, pattern or
password to unlock.
|
boolean |
isDeviceLocked(int userId)
Per-user version of
isDeviceLocked() . |
boolean |
isDeviceSecure()
Returns whether the device is secured with a PIN, pattern or
password.
|
boolean |
isDeviceSecure(int userId)
Per-user version of
isDeviceSecure() . |
boolean |
isKeyguardLocked()
Return whether the keyguard is currently locked.
|
boolean |
isKeyguardSecure()
Return whether the keyguard is secured by a PIN, pattern or password or a SIM card
is currently locked.
|
KeyguardManager.KeyguardLock |
newKeyguardLock(String tag)
Deprecated.
Use
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
and/or WindowManager.LayoutParams.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.
Enables you to lock or unlock the keyboard. Get an instance of this class by
calling Context.getSystemService() .
This class is wrapped by KeyguardManager . |
public static final String ACTION_CONFIRM_DEVICE_CREDENTIAL
public static final String ACTION_CONFIRM_DEVICE_CREDENTIAL_WITH_USER
public static final String EXTRA_TITLE
ACTION_CONFIRM_DEVICE_CREDENTIAL
.public static final String EXTRA_DESCRIPTION
ACTION_CONFIRM_DEVICE_CREDENTIAL
.public Intent createConfirmDeviceCredentialIntent(CharSequence title, CharSequence description)
Activity.startActivityForResult(Intent, int)
and check for
Activity.RESULT_OK
if the user successfully completes the challenge.public Intent createConfirmDeviceCredentialIntent(CharSequence title, CharSequence description, int userId)
Activity.startActivityForResult(Intent, int)
and check for
Activity.RESULT_OK
if the user successfully completes the challenge.@Deprecated public KeyguardManager.KeyguardLock newKeyguardLock(String tag)
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
and/or WindowManager.LayoutParams.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.
Enables you to lock or unlock the keyboard. Get an instance of this class by
calling Context.getSystemService()
.
This class is wrapped by KeyguardManager
.tag
- A tag that informally identifies who you are (for debugging who
is disabling he keyguard).KeyguardManager.KeyguardLock
handle to use to disable and reenable the
keyguard.public boolean isKeyguardLocked()
public boolean isKeyguardSecure()
See also isDeviceSecure()
which ignores SIM locked states.
public boolean inKeyguardRestrictedInputMode()
WindowManagerPolicy.inKeyguardRestrictedKeyInputMode()
public boolean isDeviceLocked()
public boolean isDeviceLocked(int userId)
isDeviceLocked()
.public boolean isDeviceSecure()
See also isKeyguardSecure()
which treats SIM locked states as secure.
public boolean isDeviceSecure(int userId)
isDeviceSecure()
.@Deprecated public void exitKeyguardSecurely(KeyguardManager.OnKeyguardExitResult callback)
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
and/or WindowManager.LayoutParams.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.
Exit the keyguard securely. The use case for this api is that, after
disabling the keyguard, your app, which was granted permission to
disable the keyguard and show a limited amount of information deemed
safe without the user getting past the keyguard, needs to navigate to
something that is not safe to view without getting past the keyguard.
This will, if the keyguard is secure, bring up the unlock screen of
the keyguard.
This method requires the caller to hold the permission
android.Manifest.permission#DISABLE_KEYGUARD
.
callback
- Let's you know whether the operation was succesful and
it is safe to launch anything that would normally be considered safe
once the user has gotten past the keyguard.