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