KeyguardManager
public
class
KeyguardManager
extends Object
| java.lang.Object | |
| ↳ | android.app.KeyguardManager |
Class that can be used to lock and unlock the keyboard. Get an instance of this
class by calling getSystemService(java.lang.String)
with argument KEYGUARD_SERVICE. The
actual class to control the keyboard locking is
KeyguardManager.KeyguardLock.
Summary
Nested classes | |
|---|---|
class |
KeyguardManager.KeyguardDismissCallback
Callback passed to |
class |
KeyguardManager.KeyguardLock
This class was deprecated
in API level 13.
Use |
interface |
KeyguardManager.OnKeyguardExitResult
This interface was deprecated
in API level O.
Use |
Public methods | |
|---|---|
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. |
void
|
exitKeyguardSecurely(KeyguardManager.OnKeyguardExitResult callback)
This method was deprecated
in API level 13.
Use |
boolean
|
inKeyguardRestrictedInputMode()
If keyguard screen is showing or in restricted key input mode (i.e. |
boolean
|
isDeviceLocked()
Returns whether the device is currently locked and requires a PIN, pattern or password to unlock. |
boolean
|
isDeviceSecure()
Returns whether the device is secured with a PIN, pattern or password. |
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)
This method was deprecated
in API level 13.
Use |
void
|
requestDismissKeyguard(Activity activity, KeyguardManager.KeyguardDismissCallback callback)
If the device is currently locked (see |
Inherited methods | |
|---|---|
java.lang.Object
| |
Public methods
createConfirmDeviceCredentialIntent
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. The caller is expected to launch this activity using
startActivityForResult(Intent, int) and check for
RESULT_OK if the user successfully completes the challenge.
| Parameters | |
|---|---|
title |
CharSequence |
description |
CharSequence |
| Returns | |
|---|---|
Intent |
the intent for launching the activity or null if no password is required. |
exitKeyguardSecurely
void exitKeyguardSecurely (KeyguardManager.OnKeyguardExitResult callback)
This method 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.
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.
Requires the DISABLE_KEYGUARD permission.
| Parameters | |
|---|---|
callback |
KeyguardManager.OnKeyguardExitResult: 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.
|
inKeyguardRestrictedInputMode
boolean inKeyguardRestrictedInputMode ()
If keyguard screen is showing or in restricted key input mode (i.e. in keyguard password emergency screen). When in such mode, certain keys, such as the Home key and the right soft keys, don't work.
| Returns | |
|---|---|
boolean |
true if in keyguard restricted input mode. |
See also:
- inKeyguardRestrictedKeyInputMode()
isDeviceLocked
boolean isDeviceLocked ()
Returns whether the device is currently locked and requires a PIN, pattern or password to unlock.
| Returns | |
|---|---|
boolean |
true if unlocking the device currently requires a PIN, pattern or password. |
isDeviceSecure
boolean isDeviceSecure ()
Returns whether the device is secured with a PIN, pattern or password.
See also isKeyguardSecure() which treats SIM locked states as secure.
| Returns | |
|---|---|
boolean |
true if a PIN, pattern or password was set. |
isKeyguardLocked
boolean isKeyguardLocked ()
Return whether the keyguard is currently locked.
| Returns | |
|---|---|
boolean |
true if keyguard is locked. |
isKeyguardSecure
boolean isKeyguardSecure ()
Return whether the keyguard is secured by a PIN, pattern or password or a SIM card is currently locked.
See also isDeviceSecure() which ignores SIM locked states.
| Returns | |
|---|---|
boolean |
true if a PIN, pattern or password is set or a SIM card is locked. |
newKeyguardLock
KeyguardManager.KeyguardLock newKeyguardLock (String tag)
This method 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.
Enables you to lock or unlock the keyboard. Get an instance of this class by
calling Context.getSystemService().
This class is wrapped by KeyguardManager.
| Parameters | |
|---|---|
tag |
String: A tag that informally identifies who you are (for debugging who
is disabling he keyguard). |
| Returns | |
|---|---|
KeyguardManager.KeyguardLock |
A KeyguardManager.KeyguardLock handle to use to disable and reenable the
keyguard.
|
requestDismissKeyguard
void requestDismissKeyguard (Activity activity, KeyguardManager.KeyguardDismissCallback callback)
If the device is currently locked (see isKeyguardLocked(), requests the Keyguard to
be dismissed.
If the Keyguard is not secure or the device is currently in a trusted state, calling this method will immediately dismiss the Keyguard without any user interaction.
If the Keyguard is secure and the device is not in a trusted state, this will bring up the UI so the user can enter their credentials.
| Parameters | |
|---|---|
activity |
Activity: The activity requesting the dismissal. The activity must be either visible
by using FLAG_SHOW_WHEN_LOCKED or must be in a state in
which it would be visible if Keyguard would not be hiding it. If that's not
the case, the request will fail immediately and
onDismissError() will be invoked.This value must never be |
callback |
KeyguardManager.KeyguardDismissCallback: The callback to be called if the request to dismiss Keyguard was successful
or null if the caller isn't interested in knowing the result. The
callback will not be invoked if the activity was destroyed before the
callback was received.
This value may be |
Interfaces
- ActionBar.OnMenuVisibilityListener
- ActionBar.OnNavigationListener
- ActionBar.TabListener
- AlarmManager.OnAlarmListener
- Application.ActivityLifecycleCallbacks
- Application.OnProvideAssistDataListener
- AppOpsManager.OnOpChangedListener
- DatePickerDialog.OnDateSetListener
- FragmentBreadCrumbs.OnBreadCrumbClickListener
- FragmentManager.BackStackEntry
- FragmentManager.OnBackStackChangedListener
- KeyguardManager.OnKeyguardExitResult
- LoaderManager.LoaderCallbacks
- Notification.Action.Extender
- Notification.Extender
- PendingIntent.OnFinished
- SearchManager.OnCancelListener
- SearchManager.OnDismissListener
- SharedElementCallback.OnSharedElementsReadyListener
- TimePickerDialog.OnTimeSetListener
- UiAutomation.AccessibilityEventFilter
- UiAutomation.OnAccessibilityEventListener
Classes
- ActionBar
- ActionBar.LayoutParams
- ActionBar.Tab
- Activity
- ActivityGroup
- ActivityManager
- ActivityManager.AppTask
- ActivityManager.MemoryInfo
- ActivityManager.ProcessErrorStateInfo
- ActivityManager.RecentTaskInfo
- ActivityManager.RunningAppProcessInfo
- ActivityManager.RunningServiceInfo
- ActivityManager.RunningTaskInfo
- ActivityManager.TaskDescription
- ActivityOptions
- AlarmManager
- AlarmManager.AlarmClockInfo
- AlertDialog
- AlertDialog.Builder
- AliasActivity
- Application
- ApplicationErrorReport
- ApplicationErrorReport.AnrInfo
- ApplicationErrorReport.BatteryInfo
- ApplicationErrorReport.CrashInfo
- ApplicationErrorReport.RunningServiceInfo
- AppOpsManager
- AutomaticZenRule
- DatePickerDialog
- Dialog
- DialogFragment
- DownloadManager
- DownloadManager.Query
- DownloadManager.Request
- ExpandableListActivity
- Fragment
- Fragment.SavedState
- FragmentBreadCrumbs
- FragmentContainer
- FragmentController
- FragmentHostCallback
- FragmentManager
- FragmentManager.FragmentLifecycleCallbacks
- FragmentManagerNonConfig
- FragmentTransaction
- Instrumentation
- Instrumentation.ActivityMonitor
- Instrumentation.ActivityResult
- IntentService
- KeyguardManager
- KeyguardManager.KeyguardDismissCallback
- KeyguardManager.KeyguardLock
- LauncherActivity
- LauncherActivity.IconResizer
- LauncherActivity.ListItem
- ListActivity
- ListFragment
- LoaderManager
- LocalActivityManager
- MediaRouteActionProvider
- MediaRouteButton
- NativeActivity
- Notification
- Notification.Action
- Notification.Action.Builder
- Notification.Action.WearableExtender
- Notification.BigPictureStyle
- Notification.BigTextStyle
- Notification.Builder
- Notification.CarExtender
- Notification.CarExtender.Builder
- Notification.CarExtender.UnreadConversation
- Notification.DecoratedCustomViewStyle
- Notification.DecoratedMediaCustomViewStyle
- Notification.InboxStyle
- Notification.MediaStyle
- Notification.MessagingStyle
- Notification.MessagingStyle.Message
- Notification.Style
- Notification.WearableExtender
- NotificationChannel
- NotificationChannelGroup
- NotificationManager
- NotificationManager.Policy
- PendingIntent
- PictureInPictureParams
- PictureInPictureParams.Builder
- Presentation
- ProgressDialog
- RemoteAction
- RemoteInput
- RemoteInput.Builder
- SearchableInfo
- SearchManager
- Service
- SharedElementCallback
- TabActivity
- TaskStackBuilder
- TimePickerDialog
- UiAutomation
- UiModeManager
- VoiceInteractor
- VoiceInteractor.AbortVoiceRequest
- VoiceInteractor.CommandRequest
- VoiceInteractor.CompleteVoiceRequest
- VoiceInteractor.ConfirmationRequest
- VoiceInteractor.PickOptionRequest
- VoiceInteractor.PickOptionRequest.Option
- VoiceInteractor.Prompt
- VoiceInteractor.Request
- WallpaperInfo
- WallpaperManager
Exceptions