Added in API level 8

DeviceAdminReceiver


open class DeviceAdminReceiver : BroadcastReceiver
kotlin.Any
   ↳ android.content.BroadcastReceiver
   ↳ android.app.admin.DeviceAdminReceiver

Base class for implementing a device administration component. This class provides a convenience for interpreting the raw intent actions that are sent by the system.

The callback methods, like the base BroadcastReceiver.onReceive() method, happen on the main thread of the process. Thus long running operations must be done on another thread. Note that because a receiver is done once returning from its receive function, such long-running operations should probably be done in a Service.

When publishing your DeviceAdmin subclass as a receiver, it must handle ACTION_DEVICE_ADMIN_ENABLED and require the android.Manifest.permission#BIND_DEVICE_ADMIN permission. A typical manifest entry would look like:

The meta-data referenced here provides addition information specific to the device administrator, as parsed by the DeviceAdminInfo class. A typical file would be:

Summary

Constants
static String

Broadcast action: notify that some app is attempting to choose a KeyChain key.

static String

Action sent to a device administrator when the user has disabled it.

static String

Action sent to a device administrator when the user has requested to disable it, but before this has actually been done.

static String

This is the primary action that a device administrator must implement to be allowed to manage a device.

static String

Action sent to a device administrator to notify that the device is entering lock task mode.

static String

Action sent to a device administrator to notify that the device is exiting lock task mode.

static String

Broadcast action: notify that a new batch of network logs is ready to be collected.

static String

Action sent to a device administrator when the user has changed the password of their device or profile challenge.

static String

Action periodically sent to a device administrator when the device or profile challenge password is expiring.

static String

Action sent to a device administrator when the user has entered an incorrect device or profile challenge password.

static String

Action sent to a device administrator when the user has successfully entered their device or profile challenge password, after failing one or more times.

static String

Broadcast Action: This broadcast is sent to indicate that provisioning of a managed profile or managed device has completed successfully.

static String

Broadcast action: notify that a new batch of security logs is ready to be collected.

static Int

Bugreport completion process failed.

static Int

Bugreport has been created, but is no longer available for collection.

static String

Name under which a DevicePolicy component publishes information about itself.

static String

A CharSequence that can be shown to the user informing them of the impact of disabling your admin.

static String

A string containing the name of the package entering lock task mode.

static String

A android.os.Parcelable extra of type android.os.PersistableBundle that allows a mobile device management application to pass data to the management application instance after owner transfer.

Public constructors

Public methods
open DevicePolicyManager
getManager(context: Context)

Retrieve the DevicePolicyManager interface for this administrator to work with the system.

open ComponentName
getWho(context: Context)

Retrieve the ComponentName describing who this device administrator is, for use in DevicePolicyManager APIs that require the administrator to identify itself.

open Unit
onBugreportFailed(context: Context, intent: Intent, failureCode: Int)

Called when the bugreport collection flow has failed.

open Unit
onBugreportShared(context: Context, intent: Intent, bugreportHash: String)

Called when the bugreport has been shared with the device administrator app.

open Unit

Called when sharing a bugreport has been cancelled by the user of the device.

open String?
onChoosePrivateKeyAlias(context: Context, intent: Intent, uid: Int, uri: Uri?, alias: String?)

Allows this receiver to select the alias for a private key and certificate pair for authentication.

open Unit

Called to notify a profile owner of an organization-owned device that it needs to acknowledge device compliance to allow the user to turn the profile off if needed according to the maximum profile time off policy.

open CharSequence?
onDisableRequested(context: Context, intent: Intent)

Called when the user has asked to disable the administrator, as a result of receiving ACTION_DEVICE_ADMIN_DISABLE_REQUESTED, giving you a chance to present a warning message to them.

open Unit
onDisabled(context: Context, intent: Intent)

Called prior to the administrator being disabled, as a result of receiving ACTION_DEVICE_ADMIN_DISABLED.

open Unit
onEnabled(context: Context, intent: Intent)

Called after the administrator is first enabled, as a result of receiving ACTION_DEVICE_ADMIN_ENABLED.

open Unit
onLockTaskModeEntering(context: Context, intent: Intent, pkg: String)

Called when a device is entering lock task mode.

open Unit
onLockTaskModeExiting(context: Context, intent: Intent)

Called when a device is exiting lock task mode.

open Unit
onNetworkLogsAvailable(context: Context, intent: Intent, batchToken: Long, networkLogsCount: Int)

Called each time a new batch of network logs can be retrieved.

open Unit
onOperationSafetyStateChanged(context: Context, reason: Int, isSafe: Boolean)

Called to notify the state of operations that can be unsafe to execute has changed.

open Unit
onPasswordChanged(context: Context, intent: Intent)

Called after the user has changed their device or profile challenge password, as a result of receiving ACTION_PASSWORD_CHANGED.

open Unit
onPasswordChanged(context: Context, intent: Intent, user: UserHandle)

Called after the user has changed their device or profile challenge password, as a result of receiving ACTION_PASSWORD_CHANGED.

open Unit
onPasswordExpiring(context: Context, intent: Intent)

Called periodically when the device or profile challenge password is about to expire or has expired.

open Unit
onPasswordExpiring(context: Context, intent: Intent, user: UserHandle)

Called periodically when the device or profile challenge password is about to expire or has expired.

open Unit
onPasswordFailed(context: Context, intent: Intent)

Called after the user has failed at entering their device or profile challenge password, as a result of receiving ACTION_PASSWORD_FAILED.

open Unit
onPasswordFailed(context: Context, intent: Intent, user: UserHandle)

Called after the user has failed at entering their device or profile challenge password, as a result of receiving ACTION_PASSWORD_FAILED.

open Unit
onPasswordSucceeded(context: Context, intent: Intent)

Called after the user has succeeded at entering their device or profile challenge password, as a result of receiving ACTION_PASSWORD_SUCCEEDED.

open Unit
onPasswordSucceeded(context: Context, intent: Intent, user: UserHandle)

Called after the user has succeeded at entering their device or profile challenge password, as a result of receiving ACTION_PASSWORD_SUCCEEDED.

open Unit

Called when provisioning of a managed profile or managed device has completed successfully.

open Unit

Called during provisioning of a managed device to allow the device initializer to perform user setup steps.

open Unit
onReceive(context: Context, intent: Intent)

Intercept standard device administrator broadcasts.

open Unit

Called when a new batch of security logs can be retrieved.

open Unit
onSystemUpdatePending(context: Context, intent: Intent, receivedTime: Long)

Called when the information about a pending system update is available.

open Unit

Called on the device owner when the ownership of one of its affiliated profiles is transferred.

open Unit

Called on the newly assigned owner (either device owner or profile owner) when the ownership transfer has completed successfully.

open Unit
onUserAdded(context: Context, intent: Intent, addedUser: UserHandle)

Called when a user or profile is created.

open Unit
onUserRemoved(context: Context, intent: Intent, removedUser: UserHandle)

Called when a user or profile is removed.

open Unit
onUserStarted(context: Context, intent: Intent, startedUser: UserHandle)

Called when a user or profile is started.

open Unit
onUserStopped(context: Context, intent: Intent, stoppedUser: UserHandle)

Called when a user or profile is stopped.

open Unit
onUserSwitched(context: Context, intent: Intent, switchedUser: UserHandle)

Called when a user or profile is switched to.

Inherited functions

Constants

ACTION_CHOOSE_PRIVATE_KEY_ALIAS

Added in API level 29
static val ACTION_CHOOSE_PRIVATE_KEY_ALIAS: String

Broadcast action: notify that some app is attempting to choose a KeyChain key.

Value: "android.app.action.CHOOSE_PRIVATE_KEY_ALIAS"

ACTION_DEVICE_ADMIN_DISABLED

Added in API level 8
static val ACTION_DEVICE_ADMIN_DISABLED: String

Action sent to a device administrator when the user has disabled it. Upon return, the application no longer has access to the protected device policy manager APIs. You will generally handle this in DeviceAdminReceiver.onDisabled(Context, Intent). Note that this action will be sent the receiver regardless of whether it is explicitly listed in its intent filter.

Value: "android.app.action.DEVICE_ADMIN_DISABLED"

ACTION_DEVICE_ADMIN_DISABLE_REQUESTED

Added in API level 8
static val ACTION_DEVICE_ADMIN_DISABLE_REQUESTED: String

Action sent to a device administrator when the user has requested to disable it, but before this has actually been done. This gives you a chance to supply a message to the user about the impact of disabling your admin, by setting the extra field EXTRA_DISABLE_WARNING in the result Intent. If not set, no warning will be displayed. If set, the given text will be shown to the user before they disable your admin.

Value: "android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED"

ACTION_DEVICE_ADMIN_ENABLED

Added in API level 8
static val ACTION_DEVICE_ADMIN_ENABLED: String

This is the primary action that a device administrator must implement to be allowed to manage a device. This will be set to the receiver when the user enables it for administration. You will generally handle this in DeviceAdminReceiver.onEnabled(Context, Intent). To be supported, the receiver must also require the android.Manifest.permission#BIND_DEVICE_ADMIN permission so that other applications can not abuse it.

Value: "android.app.action.DEVICE_ADMIN_ENABLED"

ACTION_LOCK_TASK_ENTERING

Added in API level 21
static val ACTION_LOCK_TASK_ENTERING: String

Action sent to a device administrator to notify that the device is entering lock task mode. The extra EXTRA_LOCK_TASK_PACKAGE will describe the package using lock task mode.

The calling device admin must be the device owner or profile owner to receive this broadcast.

Value: "android.app.action.LOCK_TASK_ENTERING"

ACTION_LOCK_TASK_EXITING

Added in API level 21
static val ACTION_LOCK_TASK_EXITING: String

Action sent to a device administrator to notify that the device is exiting lock task mode.

The calling device admin must be the device owner or profile owner to receive this broadcast.

Value: "android.app.action.LOCK_TASK_EXITING"

ACTION_NETWORK_LOGS_AVAILABLE

Added in API level 29
static val ACTION_NETWORK_LOGS_AVAILABLE: String

Broadcast action: notify that a new batch of network logs is ready to be collected.

Value: "android.app.action.NETWORK_LOGS_AVAILABLE"

ACTION_PASSWORD_CHANGED

Added in API level 8
static val ACTION_PASSWORD_CHANGED: String

Action sent to a device administrator when the user has changed the password of their device or profile challenge. You can at this point check the characteristics of the new password with DevicePolicyManager.isActivePasswordSufficient(). You will generally handle this in DeviceAdminReceiver.onPasswordChanged(Context, Intent, UserHandle).

The calling device admin must have requested DeviceAdminInfo.USES_POLICY_LIMIT_PASSWORD to receive this broadcast.

Value: "android.app.action.ACTION_PASSWORD_CHANGED"

ACTION_PASSWORD_EXPIRING

Added in API level 11
static val ACTION_PASSWORD_EXPIRING: String

Action periodically sent to a device administrator when the device or profile challenge password is expiring. You will generally handle this in DeviceAdminReceiver.onPasswordExpiring(Context, Intent, UserHandle).

The calling device admin must have requested DeviceAdminInfo.USES_POLICY_EXPIRE_PASSWORD to receive this broadcast.

Value: "android.app.action.ACTION_PASSWORD_EXPIRING"

ACTION_PASSWORD_FAILED

Added in API level 8
static val ACTION_PASSWORD_FAILED: String

Action sent to a device administrator when the user has entered an incorrect device or profile challenge password. You can at this point check the number of failed password attempts there have been with DevicePolicyManager.getCurrentFailedPasswordAttempts(). You will generally handle this in DeviceAdminReceiver.onPasswordFailed(Context, Intent, UserHandle).

The calling device admin must have requested DeviceAdminInfo.USES_POLICY_WATCH_LOGIN to receive this broadcast.

Value: "android.app.action.ACTION_PASSWORD_FAILED"

ACTION_PASSWORD_SUCCEEDED

Added in API level 8
static val ACTION_PASSWORD_SUCCEEDED: String

Action sent to a device administrator when the user has successfully entered their device or profile challenge password, after failing one or more times. You will generally handle this in DeviceAdminReceiver.onPasswordSucceeded(Context, Intent, UserHandle).

The calling device admin must have requested DeviceAdminInfo.USES_POLICY_WATCH_LOGIN to receive this broadcast.

Value: "android.app.action.ACTION_PASSWORD_SUCCEEDED"

ACTION_PROFILE_PROVISIONING_COMPLETE

Added in API level 21
static val ACTION_PROFILE_PROVISIONING_COMPLETE: String

Broadcast Action: This broadcast is sent to indicate that provisioning of a managed profile or managed device has completed successfully.

The broadcast is limited to the profile that will be managed by the application that requested provisioning. In the device owner case the profile is the primary user. The broadcast will also be limited to the DeviceAdminReceiver component specified in the original intent or NFC bump that started the provisioning process (see DevicePolicyManager.ACTION_PROVISION_MANAGED_PROFILE).

A device admin application which listens to this intent can find out if the device was provisioned for the device owner or profile owner case by calling respectively android.app.admin.DevicePolicyManager#isDeviceOwnerApp and android.app.admin.DevicePolicyManager#isProfileOwnerApp. You will generally handle this in DeviceAdminReceiver.onProfileProvisioningComplete.

The intent for this action may include the following extras:

Value: "android.app.action.PROFILE_PROVISIONING_COMPLETE"

ACTION_SECURITY_LOGS_AVAILABLE

Added in API level 31
static val ACTION_SECURITY_LOGS_AVAILABLE: String

Broadcast action: notify that a new batch of security logs is ready to be collected.

Value: "android.app.action.SECURITY_LOGS_AVAILABLE"

BUGREPORT_FAILURE_FAILED_COMPLETING

Added in API level 24
static val BUGREPORT_FAILURE_FAILED_COMPLETING: Int

Bugreport completion process failed.

If this error code is received, the requesting of bugreport can be retried.

Value: 0

BUGREPORT_FAILURE_FILE_NO_LONGER_AVAILABLE

Added in API level 24
static val BUGREPORT_FAILURE_FILE_NO_LONGER_AVAILABLE: Int

Bugreport has been created, but is no longer available for collection.

This error likely occurs because the user of the device hasn't consented to share the bugreport for a long period after its creation.

If this error code is received, the requesting of bugreport can be retried.

Value: 1

DEVICE_ADMIN_META_DATA

Added in API level 8
static val DEVICE_ADMIN_META_DATA: String

Name under which a DevicePolicy component publishes information about itself. This meta-data must reference an XML resource containing a device-admin tag.

Value: "android.app.device_admin"

EXTRA_DISABLE_WARNING

Added in API level 8
static val EXTRA_DISABLE_WARNING: String

A CharSequence that can be shown to the user informing them of the impact of disabling your admin.

Value: "android.app.extra.DISABLE_WARNING"

EXTRA_LOCK_TASK_PACKAGE

Added in API level 21
static val EXTRA_LOCK_TASK_PACKAGE: String

A string containing the name of the package entering lock task mode.

Value: "android.app.extra.LOCK_TASK_PACKAGE"

EXTRA_TRANSFER_OWNERSHIP_ADMIN_EXTRAS_BUNDLE

Added in API level 28
static val EXTRA_TRANSFER_OWNERSHIP_ADMIN_EXTRAS_BUNDLE: String

A android.os.Parcelable extra of type android.os.PersistableBundle that allows a mobile device management application to pass data to the management application instance after owner transfer.

If the transfer is successful, the new owner receives the data in DeviceAdminReceiver.onTransferOwnershipComplete(Context, PersistableBundle). The bundle is not changed during the ownership transfer.

Value: "android.app.extra.TRANSFER_OWNERSHIP_ADMIN_EXTRAS_BUNDLE"

Public constructors

DeviceAdminReceiver

DeviceAdminReceiver()

Public methods

getManager

Added in API level 8
open fun getManager(context: Context): DevicePolicyManager

Retrieve the DevicePolicyManager interface for this administrator to work with the system.

Parameters
context Context: This value cannot be null.
Return
DevicePolicyManager This value cannot be null.

getWho

Added in API level 8
open fun getWho(context: Context): ComponentName

Retrieve the ComponentName describing who this device administrator is, for use in DevicePolicyManager APIs that require the administrator to identify itself.

Parameters
context Context: This value cannot be null.
Return
ComponentName This value cannot be null.

onBugreportFailed

Added in API level 24
open fun onBugreportFailed(
    context: Context,
    intent: Intent,
    failureCode: Int
): Unit

Called when the bugreport collection flow has failed.

This callback is only applicable to device owners.

Parameters
context Context: The running context as per onReceive. This value cannot be null.
intent Intent: The received intent as per onReceive. This value cannot be null.
failureCode Int: int containing failure code. One of BUGREPORT_FAILURE_FAILED_COMPLETING or BUGREPORT_FAILURE_FILE_NO_LONGER_AVAILABLE Value is android.app.admin.DeviceAdminReceiver#BUGREPORT_FAILURE_FAILED_COMPLETING, or android.app.admin.DeviceAdminReceiver#BUGREPORT_FAILURE_FILE_NO_LONGER_AVAILABLE

onBugreportShared

Added in API level 24
open fun onBugreportShared(
    context: Context,
    intent: Intent,
    bugreportHash: String
): Unit

Called when the bugreport has been shared with the device administrator app.

This callback is only applicable to device owners.

Parameters
context Context: The running context as per onReceive. This value cannot be null.
intent Intent: The received intent as per onReceive. Contains the URI of the bugreport file (with MIME type "application/vnd.android.bugreport"), that can be accessed by calling Intent.getData() This value cannot be null.
bugreportHash String: SHA-256 hash of the bugreport file. This value cannot be null.

onBugreportSharingDeclined

Added in API level 24
open fun onBugreportSharingDeclined(
    context: Context,
    intent: Intent
): Unit

Called when sharing a bugreport has been cancelled by the user of the device.

This callback is only applicable to device owners.

Parameters
context Context: The running context as per onReceive. This value cannot be null.
intent Intent: The received intent as per onReceive. This value cannot be null.

onChoosePrivateKeyAlias

Added in API level 23
open fun onChoosePrivateKeyAlias(
    context: Context,
    intent: Intent,
    uid: Int,
    uri: Uri?,
    alias: String?
): String?

Allows this receiver to select the alias for a private key and certificate pair for authentication. If this method returns null, the default android.app.Activity will be shown that lets the user pick a private key and certificate pair. If this method returns KeyChain.KEY_ALIAS_SELECTION_DENIED, the default android.app.Activity will not be shown and the user will not be allowed to pick anything. And the app, that called android.security.KeyChain#choosePrivateKeyAlias, will receive null back.

Parameters
context Context: The running context as per onReceive. This value cannot be null.
intent Intent: The received intent as per onReceive. This value cannot be null.
uid Int: The uid of the app asking for the private key and certificate pair.
uri Uri?: The URI to authenticate, may be null.
alias String?: The alias preselected by the client, or null.
Return
String? The private key alias to return and grant access to.

See Also

    onComplianceAcknowledgementRequired

    Added in API level 31
    open fun onComplianceAcknowledgementRequired(
        context: Context,
        intent: Intent
    ): Unit

    Called to notify a profile owner of an organization-owned device that it needs to acknowledge device compliance to allow the user to turn the profile off if needed according to the maximum profile time off policy. Default implementation acknowledges compliance immediately. DPC may prefer to override this implementation to delay acknowledgement until a successful policy sync. Until compliance is acknowledged the user is still free to turn the profile off, but the timer won't be reset, so personal apps will be suspended sooner. This callback is delivered using a foreground broadcast and should be handled quickly.

    Parameters
    context Context: the running context as per onReceive This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.

    onDisableRequested

    Added in API level 8
    open fun onDisableRequested(
        context: Context,
        intent: Intent
    ): CharSequence?

    Called when the user has asked to disable the administrator, as a result of receiving ACTION_DEVICE_ADMIN_DISABLE_REQUESTED, giving you a chance to present a warning message to them. The message is returned as the result; if null is returned (the default implementation), no message will be displayed.

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.
    Return
    CharSequence? Return the warning message to display to the user before being disabled; if null is returned, no message is displayed.

    onDisabled

    Added in API level 8
    open fun onDisabled(
        context: Context,
        intent: Intent
    ): Unit

    Called prior to the administrator being disabled, as a result of receiving ACTION_DEVICE_ADMIN_DISABLED. Upon return, you can no longer use the protected parts of the DevicePolicyManager API.

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.

    onEnabled

    Added in API level 8
    open fun onEnabled(
        context: Context,
        intent: Intent
    ): Unit

    Called after the administrator is first enabled, as a result of receiving ACTION_DEVICE_ADMIN_ENABLED. At this point you can use DevicePolicyManager to set your desired policies.

    If the admin is activated by a device owner, then the intent may contain private extras that are relevant to user setup. {@see DevicePolicyManager#createAndManageUser(ComponentName, String, ComponentName, * PersistableBundle, int)}

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.

    onLockTaskModeEntering

    Added in API level 21
    open fun onLockTaskModeEntering(
        context: Context,
        intent: Intent,
        pkg: String
    ): Unit

    Called when a device is entering lock task mode.

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.
    pkg String: The authorized package using lock task mode. This value cannot be null.

    onLockTaskModeExiting

    Added in API level 21
    open fun onLockTaskModeExiting(
        context: Context,
        intent: Intent
    ): Unit

    Called when a device is exiting lock task mode.

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.

    onNetworkLogsAvailable

    Added in API level 26
    open fun onNetworkLogsAvailable(
        context: Context,
        intent: Intent,
        batchToken: Long,
        networkLogsCount: Int
    ): Unit

    Called each time a new batch of network logs can be retrieved. This callback method will only ever be called when network logging is enabled. The logs can only be retrieved while network logging is enabled.

    If a secondary user or profile is created, this callback won't be received until all users become affiliated again (even if network logging is enabled). It will also no longer be possible to retrieve the network logs batch with the most recent batchToken provided by this callback. See DevicePolicyManager.setAffiliationIds.

    This callback is only applicable to device owners and profile owners.

    This callback is triggered by a foreground broadcast and the app should ensure that any long-running work is not executed synchronously inside the callback.

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.
    batchToken Long: The token representing the current batch of network logs.
    networkLogsCount Int: The total count of events in the current batch of network logs. Value is 1 or greater

    onOperationSafetyStateChanged

    Added in API level 31
    open fun onOperationSafetyStateChanged(
        context: Context,
        reason: Int,
        isSafe: Boolean
    ): Unit

    Called to notify the state of operations that can be unsafe to execute has changed.

    Note: notice that the operation safety state might change between the time this callback is received and the operation's method on DevicePolicyManager is called, so calls to the latter could still throw a UnsafeStateException even when this method is called with isSafe as true

    Parameters
    context Context: the running context as per onReceive This value cannot be null.
    reason Int: the reason an operation could be unsafe. Value is android.app.admin.DevicePolicyManager.OPERATION_SAFETY_REASON_NONE, or android.app.admin.DevicePolicyManager#OPERATION_SAFETY_REASON_DRIVING_DISTRACTION
    isSafe Boolean: whether the operation is safe to be executed.

    onPasswordChanged

    Added in API level 8
    Deprecated in API level 26
    open fun onPasswordChanged(
        context: Context,
        intent: Intent
    ): Unit

    Deprecated: From android.os.Build.VERSION_CODES#O, use onPasswordChanged(android.content.Context,android.content.Intent,android.os.UserHandle) instead.

    Called after the user has changed their device or profile challenge password, as a result of receiving ACTION_PASSWORD_CHANGED. At this point you can use DevicePolicyManager.getPasswordQuality(android.content.ComponentName) to retrieve the active password characteristics.

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.

    onPasswordChanged

    Added in API level 26
    open fun onPasswordChanged(
        context: Context,
        intent: Intent,
        user: UserHandle
    ): Unit

    Called after the user has changed their device or profile challenge password, as a result of receiving ACTION_PASSWORD_CHANGED. At this point you can use DevicePolicyManager.getPasswordQuality(android.content.ComponentName) to retrieve the active password characteristics.

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.
    user UserHandle: The user or profile for whom the password changed. To see whether this user is the current profile or a parent user, check for equality with Process.myUserHandle. This value cannot be null.

    onPasswordExpiring

    Added in API level 11
    Deprecated in API level 26
    open fun onPasswordExpiring(
        context: Context,
        intent: Intent
    ): Unit

    Deprecated: From android.os.Build.VERSION_CODES#O, use onPasswordExpiring(android.content.Context,android.content.Intent,android.os.UserHandle) instead.

    Called periodically when the device or profile challenge password is about to expire or has expired. It will typically be called at these times: on device boot, once per day before the password expires, and at the time when the password expires.

    If the password is not updated by the user, this method will continue to be called once per day until the password is changed or the device admin disables password expiration.

    The admin will typically post a notification requesting the user to change their password in response to this call. The actual password expiration time can be obtained by calling DevicePolicyManager.getPasswordExpiration(ComponentName)

    The admin should be sure to take down any notifications it posted in response to this call when it receives DeviceAdminReceiver.onPasswordChanged(Context, Intent).

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.

    onPasswordExpiring

    Added in API level 26
    open fun onPasswordExpiring(
        context: Context,
        intent: Intent,
        user: UserHandle
    ): Unit

    Called periodically when the device or profile challenge password is about to expire or has expired. It will typically be called at these times: on device boot, once per day before the password expires, and at the time when the password expires.

    If the password is not updated by the user, this method will continue to be called once per day until the password is changed or the device admin disables password expiration.

    The admin will typically post a notification requesting the user to change their password in response to this call. The actual password expiration time can be obtained by calling DevicePolicyManager.getPasswordExpiration(ComponentName)

    The admin should be sure to take down any notifications it posted in response to this call when it receives DeviceAdminReceiver.onPasswordChanged(Context, Intent, UserHandle).

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.
    user UserHandle: The user or profile for whom the password is expiring. To see whether this user is the current profile or a parent user, check for equality with Process.myUserHandle. This value cannot be null.

    onPasswordFailed

    Added in API level 8
    Deprecated in API level 26
    open fun onPasswordFailed(
        context: Context,
        intent: Intent
    ): Unit

    Deprecated: From android.os.Build.VERSION_CODES#O, use onPasswordFailed(android.content.Context,android.content.Intent,android.os.UserHandle) instead.

    Called after the user has failed at entering their device or profile challenge password, as a result of receiving ACTION_PASSWORD_FAILED. At this point you can use DevicePolicyManager.getCurrentFailedPasswordAttempts() to retrieve the number of failed password attempts.

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.

    onPasswordFailed

    Added in API level 26
    open fun onPasswordFailed(
        context: Context,
        intent: Intent,
        user: UserHandle
    ): Unit

    Called after the user has failed at entering their device or profile challenge password, as a result of receiving ACTION_PASSWORD_FAILED. At this point you can use DevicePolicyManager.getCurrentFailedPasswordAttempts() to retrieve the number of failed password attempts.

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.
    user UserHandle: The user or profile for whom the password check failed. To see whether this user is the current profile or a parent user, check for equality with Process.myUserHandle. This value cannot be null.

    onPasswordSucceeded

    Added in API level 8
    Deprecated in API level 26
    open fun onPasswordSucceeded(
        context: Context,
        intent: Intent
    ): Unit

    Deprecated: From android.os.Build.VERSION_CODES#O, use onPasswordSucceeded(android.content.Context,android.content.Intent,android.os.UserHandle) instead.

    Called after the user has succeeded at entering their device or profile challenge password, as a result of receiving ACTION_PASSWORD_SUCCEEDED. This will only be received the first time they succeed after having previously failed.

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.

    onPasswordSucceeded

    Added in API level 26
    open fun onPasswordSucceeded(
        context: Context,
        intent: Intent,
        user: UserHandle
    ): Unit

    Called after the user has succeeded at entering their device or profile challenge password, as a result of receiving ACTION_PASSWORD_SUCCEEDED. This will only be received the first time they succeed after having previously failed.

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.
    user UserHandle: The user of profile for whom the password check succeeded. To see whether this user is the current profile or a parent user, check for equality with Process.myUserHandle. This value cannot be null.

    onProfileProvisioningComplete

    Added in API level 21
    open fun onProfileProvisioningComplete(
        context: Context,
        intent: Intent
    ): Unit

    Called when provisioning of a managed profile or managed device has completed successfully.

    As a prerequisite for the execution of this callback the DeviceAdminReceiver has to declare an intent filter for ACTION_PROFILE_PROVISIONING_COMPLETE. Its component must also be specified in the DevicePolicyManager.EXTRA_DEVICE_ADMIN of the DevicePolicyManager.ACTION_PROVISION_MANAGED_PROFILE intent that started the managed provisioning.

    When provisioning of a managed profile is complete, the managed profile is hidden until the profile owner calls DevicePolicyManager.setProfileEnabled(ComponentName admin). Typically a profile owner will enable the profile when it has finished any additional setup such as adding an account by using the AccountManager and calling APIs to bring the profile into the desired state.

    Note that provisioning completes without waiting for any server interactions, so the profile owner needs to wait for data to be available if required (e.g. Android device IDs or other data that is set as a result of server interactions).

    From version android.os.Build.VERSION_CODES#O, when managed provisioning has completed, along with this callback the activity intent DevicePolicyManager.ACTION_PROVISIONING_SUCCESSFUL will also be sent to the same application.

    The Intent may include any of the extras specified for ACTION_PROFILE_PROVISIONING_COMPLETE.

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.

    onReadyForUserInitialization

    Added in API level 23
    Deprecated in API level 24
    open fun onReadyForUserInitialization(
        context: Context,
        intent: Intent
    ): Unit

    Deprecated: Do not use

    Called during provisioning of a managed device to allow the device initializer to perform user setup steps.

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.

    onReceive

    Added in API level 8
    open fun onReceive(
        context: Context,
        intent: Intent
    ): Unit

    Intercept standard device administrator broadcasts. Implementations should not override this method; it is better to implement the convenience callbacks for each action.

    Parameters
    context Context: This value cannot be null.
    intent Intent: This value cannot be null.

    onSecurityLogsAvailable

    Added in API level 24
    open fun onSecurityLogsAvailable(
        context: Context,
        intent: Intent
    ): Unit

    Called when a new batch of security logs can be retrieved.

    If a secondary user or profile is created, this callback won't be received until all users become affiliated again (even if security logging is enabled). See DevicePolicyManager.setAffiliationIds

    This callback will be re-triggered if the logs are not retrieved.

    This callback is only applicable to device owners and profile owners of organization-owned managed profiles.

    This callback is triggered by a foreground broadcast and the app should ensure that any long-running work is not executed synchronously inside the callback.

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.

    onSystemUpdatePending

    Added in API level 23
    open fun onSystemUpdatePending(
        context: Context,
        intent: Intent,
        receivedTime: Long
    ): Unit

    Called when the information about a pending system update is available.

    Allows the receiver to be notified when information about a pending system update is available from the system update service. The same pending system update can trigger multiple calls to this method, so it is necessary to examine the incoming parameters for details about the update.

    This callback is only applicable to device owners and profile owners.

    To get further information about a pending system update (for example, whether or not the update is a security patch), the device owner or profile owner can call DevicePolicyManager.getPendingSystemUpdate.

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.
    receivedTime Long: The time as given by System.currentTimeMillis() indicating when the current pending update was first available. -1 if no pending update is available.

    onTransferAffiliatedProfileOwnershipComplete

    Added in API level 28
    open fun onTransferAffiliatedProfileOwnershipComplete(
        context: Context,
        user: UserHandle
    ): Unit

    Called on the device owner when the ownership of one of its affiliated profiles is transferred.

    This can be used when transferring both device and profile ownership when using work profile on a fully managed device. The process would look like this:

    1. Transfer profile ownership
    2. The device owner gets notified with this callback
    3. Transfer device ownership
    4. Both profile and device ownerships have been transferred
    Parameters
    context Context: the running context as per onReceive This value cannot be null.
    user UserHandle: the UserHandle of the affiliated user This value cannot be null.

    onTransferOwnershipComplete

    Added in API level 28
    open fun onTransferOwnershipComplete(
        context: Context,
        bundle: PersistableBundle?
    ): Unit

    Called on the newly assigned owner (either device owner or profile owner) when the ownership transfer has completed successfully.

    The bundle parameter allows the original owner to pass data to the new one.

    Parameters
    context Context: the running context as per onReceive This value cannot be null.
    bundle PersistableBundle?: the data to be passed to the new owner This value may be null.

    onUserAdded

    Added in API level 26
    open fun onUserAdded(
        context: Context,
        intent: Intent,
        addedUser: UserHandle
    ): Unit

    Called when a user or profile is created.

    This callback is only applicable to device owners.

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.
    addedUser UserHandle: The UserHandle of the user that has just been added. This value cannot be null.

    onUserRemoved

    Added in API level 26
    open fun onUserRemoved(
        context: Context,
        intent: Intent,
        removedUser: UserHandle
    ): Unit

    Called when a user or profile is removed.

    This callback is only applicable to device owners.

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.
    removedUser UserHandle: The UserHandle of the user that has just been removed. This value cannot be null.

    onUserStarted

    Added in API level 28
    open fun onUserStarted(
        context: Context,
        intent: Intent,
        startedUser: UserHandle
    ): Unit

    Called when a user or profile is started.

    This callback is only applicable to device owners.

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.
    startedUser UserHandle: The UserHandle of the user that has just been started. This value cannot be null.

    onUserStopped

    Added in API level 28
    open fun onUserStopped(
        context: Context,
        intent: Intent,
        stoppedUser: UserHandle
    ): Unit

    Called when a user or profile is stopped.

    This callback is only applicable to device owners.

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.
    stoppedUser UserHandle: The UserHandle of the user that has just been stopped. This value cannot be null.

    onUserSwitched

    Added in API level 28
    open fun onUserSwitched(
        context: Context,
        intent: Intent,
        switchedUser: UserHandle
    ): Unit

    Called when a user or profile is switched to.

    This callback is only applicable to device owners.

    Parameters
    context Context: The running context as per onReceive. This value cannot be null.
    intent Intent: The received intent as per onReceive. This value cannot be null.
    switchedUser UserHandle: The UserHandle of the user that has just been switched to. This value cannot be null.