Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#constants) \| [Ctors](https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#pubctors) \| [Methods](https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#inhmethods)

# DeviceAdminReceiver

*** ** * ** ***


`
public


class
DeviceAdminReceiver
`


`


`

`

extends https://developer.android.com/reference/android/content/BroadcastReceiver


`

`


`

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [android.content.BroadcastReceiver](https://developer.android.com/reference/android/content/BroadcastReceiver) ||
|   | ↳ | android.app.admin.DeviceAdminReceiver |

<br />

*** ** * ** ***

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 `https://developer.android.com/reference/android/content/BroadcastReceiver#onReceive(android.content.Context,%20android.content.Intent)` 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
`https://developer.android.com/reference/android/app/Service`.

When publishing your DeviceAdmin subclass as a receiver, it must handle `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_DEVICE_ADMIN_ENABLED` and require the `https://developer.android.com/reference/android/Manifest.permission#BIND_DEVICE_ADMIN` permission. A typical manifest entry would look
like:

```
<receiver android:name=".app.DeviceAdminSample$DeviceAdminSampleReceiver"
        android:label="@string/sample_device_admin"
        android:description="@string/sample_device_admin_description"
        android:permission="android.permission.BIND_DEVICE_ADMIN">
    <meta-data android:name="android.app.device_admin"
               android:resource="@xml/device_admin_sample" />
    <intent-filter>
        <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
    </intent-filter>
</receiver>
<receiver android:name=".app.DeviceAdminSample$DeviceAdminSampleReceiver2"
    android:label="@string/sample_device_admin2"
    android:description="@string/sample_device_admin_description2"
    android:permission="android.permission.BIND_DEVICE_ADMIN">
    <meta-data android:name="android.app.device_admin"
        android:resource="@xml/device_admin_sample" />
    <intent-filter>
        <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
    </intent-filter>
</receiver>
```

The meta-data referenced here provides addition information specific to the device
administrator, as parsed by the `https://developer.android.com/reference/android/app/admin/DeviceAdminInfo` class. A typical file would be:

```
<device-admin xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-policies>
        <limit-password />
        <watch-login />
        <reset-password />
        <force-lock />
        <wipe-data />
        <expire-password />
        <encrypted-storage />
        <disable-camera />
        <disable-keyguard-features />
    </uses-policies>
</device-admin>
```

<br />

### Developer Guides

For more information about device administration, read the [Device Administration](https://developer.android.com/guide/topics/admin/device-admin) developer guide.

<br />

## Summary

| ### Constants ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_CHOOSE_PRIVATE_KEY_ALIAS` Broadcast action: notify that some app is attempting to choose a KeyChain key. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_DEVICE_ADMIN_DISABLED` Action sent to a device administrator when the user has disabled it. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_DEVICE_ADMIN_DISABLE_REQUESTED` Action sent to a device administrator when the user has requested to disable it, but before this has actually been done. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_DEVICE_ADMIN_ENABLED` This is the primary action that a device administrator must implement to be allowed to manage a device. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_LOCK_TASK_ENTERING` Action sent to a device administrator to notify that the device is entering lock task mode. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_LOCK_TASK_EXITING` Action sent to a device administrator to notify that the device is exiting lock task mode. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_NETWORK_LOGS_AVAILABLE` Broadcast action: notify that a new batch of network logs is ready to be collected. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_PASSWORD_CHANGED` Action sent to a device administrator when the user has changed the password of their device or profile challenge. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_PASSWORD_EXPIRING` Action periodically sent to a device administrator when the device or profile challenge password is expiring. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_PASSWORD_FAILED` Action sent to a device administrator when the user has entered an incorrect device or profile challenge password. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_PASSWORD_SUCCEEDED` Action sent to a device administrator when the user has successfully entered their device or profile challenge password, after failing one or more times. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_PROFILE_PROVISIONING_COMPLETE` Broadcast Action: This broadcast is sent to indicate that provisioning of a managed profile or managed device has completed successfully. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_SECURITY_LOGS_AVAILABLE` Broadcast action: notify that a new batch of security logs is ready to be collected. |
| `int` | `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#BUGREPORT_FAILURE_FAILED_COMPLETING` Bugreport completion process failed. |
| `int` | `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#BUGREPORT_FAILURE_FILE_NO_LONGER_AVAILABLE` Bugreport has been created, but is no longer available for collection. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#DEVICE_ADMIN_META_DATA` Name under which a DevicePolicy component publishes information about itself. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#EXTRA_DISABLE_WARNING` A CharSequence that can be shown to the user informing them of the impact of disabling your admin. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#EXTRA_LOCK_TASK_PACKAGE` A string containing the name of the package entering lock task mode. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#EXTRA_TRANSFER_OWNERSHIP_ADMIN_EXTRAS_BUNDLE` A `https://developer.android.com/reference/android/os/Parcelable` extra of type `https://developer.android.com/reference/android/os/PersistableBundle` that allows a mobile device management application to pass data to the management application instance after owner transfer. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#DeviceAdminReceiver()() ` |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/app/admin/DevicePolicyManager` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#getManager(android.content.Context)(https://developer.android.com/reference/android/content/Context context) ` Retrieve the DevicePolicyManager interface for this administrator to work with the system. |
| ` https://developer.android.com/reference/android/content/ComponentName` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#getWho(android.content.Context)(https://developer.android.com/reference/android/content/Context context) ` Retrieve the ComponentName describing who this device administrator is, for use in `https://developer.android.com/reference/android/app/admin/DevicePolicyManager` APIs that require the administrator to identify itself. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onBugreportFailed(android.content.Context,%20android.content.Intent,%20int)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent, int failureCode) ` Called when the bugreport collection flow has failed. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onBugreportShared(android.content.Context,%20android.content.Intent,%20java.lang.String)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent, https://developer.android.com/reference/java/lang/String bugreportHash) ` Called when the bugreport has been shared with the device administrator app. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onBugreportSharingDeclined(android.content.Context,%20android.content.Intent)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent) ` Called when sharing a bugreport has been cancelled by the user of the device. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onChoosePrivateKeyAlias(android.content.Context,%20android.content.Intent,%20int,%20android.net.Uri,%20java.lang.String)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent, int uid, https://developer.android.com/reference/android/net/Uri uri, https://developer.android.com/reference/java/lang/String alias) ` Allows this receiver to select the alias for a private key and certificate pair for authentication. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onComplianceAcknowledgementRequired(android.content.Context,%20android.content.Intent)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent) ` 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. |
| ` https://developer.android.com/reference/java/lang/CharSequence` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onDisableRequested(android.content.Context,%20android.content.Intent)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent) ` Called when the user has asked to disable the administrator, as a result of receiving `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_DEVICE_ADMIN_DISABLE_REQUESTED`, giving you a chance to present a warning message to them. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onDisabled(android.content.Context,%20android.content.Intent)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent) ` Called prior to the administrator being disabled, as a result of receiving `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_DEVICE_ADMIN_DISABLED`. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onEnabled(android.content.Context,%20android.content.Intent)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent) ` Called after the administrator is first enabled, as a result of receiving `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_DEVICE_ADMIN_ENABLED`. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onLockTaskModeEntering(android.content.Context,%20android.content.Intent,%20java.lang.String)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent, https://developer.android.com/reference/java/lang/String pkg) ` Called when a device is entering lock task mode. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onLockTaskModeExiting(android.content.Context,%20android.content.Intent)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent) ` Called when a device is exiting lock task mode. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onNetworkLogsAvailable(android.content.Context,%20android.content.Intent,%20long,%20int)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent, long batchToken, int networkLogsCount) ` Called each time a new batch of network logs can be retrieved. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onOperationSafetyStateChanged(android.content.Context,%20int,%20boolean)(https://developer.android.com/reference/android/content/Context context, int reason, boolean isSafe) ` Called to notify the state of operations that can be unsafe to execute has changed. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordChanged(android.content.Context,%20android.content.Intent,%20android.os.UserHandle)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent, https://developer.android.com/reference/android/os/UserHandle user) ` Called after the user has changed their device or profile challenge password, as a result of receiving `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_PASSWORD_CHANGED`. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordChanged(android.content.Context,%20android.content.Intent)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent) ` *This method was deprecated in API level 26. From `https://developer.android.com/reference/android/os/Build.VERSION_CODES#O`, use `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordChanged(android.content.Context,%20android.content.Intent,%20android.os.UserHandle)` instead.* |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordExpiring(android.content.Context,%20android.content.Intent)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent) ` *This method was deprecated in API level 26. From `https://developer.android.com/reference/android/os/Build.VERSION_CODES#O`, use `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordExpiring(android.content.Context,%20android.content.Intent,%20android.os.UserHandle)` instead.* |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordExpiring(android.content.Context,%20android.content.Intent,%20android.os.UserHandle)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent, https://developer.android.com/reference/android/os/UserHandle user) ` Called periodically when the device or profile challenge password is about to expire or has expired. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordFailed(android.content.Context,%20android.content.Intent,%20android.os.UserHandle)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent, https://developer.android.com/reference/android/os/UserHandle user) ` Called after the user has failed at entering their device or profile challenge password, as a result of receiving `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_PASSWORD_FAILED`. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordFailed(android.content.Context,%20android.content.Intent)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent) ` *This method was deprecated in API level 26. From `https://developer.android.com/reference/android/os/Build.VERSION_CODES#O`, use `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordFailed(android.content.Context,%20android.content.Intent,%20android.os.UserHandle)` instead.* |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordSucceeded(android.content.Context,%20android.content.Intent)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent) ` *This method was deprecated in API level 26. From `https://developer.android.com/reference/android/os/Build.VERSION_CODES#O`, use `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordSucceeded(android.content.Context,%20android.content.Intent,%20android.os.UserHandle)` instead.* |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordSucceeded(android.content.Context,%20android.content.Intent,%20android.os.UserHandle)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent, https://developer.android.com/reference/android/os/UserHandle user) ` Called after the user has succeeded at entering their device or profile challenge password, as a result of receiving `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_PASSWORD_SUCCEEDED`. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onProfileProvisioningComplete(android.content.Context,%20android.content.Intent)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent) ` Called when provisioning of a managed profile or managed device has completed successfully. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReadyForUserInitialization(android.content.Context,%20android.content.Intent)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent) ` *This method was deprecated in API level 24. Do not use* |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent) ` Intercept standard device administrator broadcasts. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onSecurityLogsAvailable(android.content.Context,%20android.content.Intent)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent) ` Called when a new batch of security logs can be retrieved. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onSystemUpdatePending(android.content.Context,%20android.content.Intent,%20long)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent, long receivedTime) ` Called when the information about a pending system update is available. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onTransferAffiliatedProfileOwnershipComplete(android.content.Context,%20android.os.UserHandle)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/os/UserHandle user) ` Called on the device owner when the ownership of one of its affiliated profiles is transferred. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onTransferOwnershipComplete(android.content.Context,%20android.os.PersistableBundle)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/os/PersistableBundle bundle) ` Called on the newly assigned owner (either device owner or profile owner) when the ownership transfer has completed successfully. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onUserAdded(android.content.Context,%20android.content.Intent,%20android.os.UserHandle)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent, https://developer.android.com/reference/android/os/UserHandle addedUser) ` Called when a user or profile is created. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onUserRemoved(android.content.Context,%20android.content.Intent,%20android.os.UserHandle)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent, https://developer.android.com/reference/android/os/UserHandle removedUser) ` Called when a user or profile is removed. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onUserStarted(android.content.Context,%20android.content.Intent,%20android.os.UserHandle)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent, https://developer.android.com/reference/android/os/UserHandle startedUser) ` Called when a user or profile is started. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onUserStopped(android.content.Context,%20android.content.Intent,%20android.os.UserHandle)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent, https://developer.android.com/reference/android/os/UserHandle stoppedUser) ` Called when a user or profile is stopped. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onUserSwitched(android.content.Context,%20android.content.Intent,%20android.os.UserHandle)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent, https://developer.android.com/reference/android/os/UserHandle switchedUser) ` Called when a user or profile is switched to. |

### Inherited methods

From class `

https://developer.android.com/reference/android/content/BroadcastReceiver

` `


final

void` `
https://developer.android.com/reference/android/content/BroadcastReceiver#abortBroadcast()()
`

Sets the flag indicating that this receiver should abort the
current broadcast; only works with broadcasts sent through
`https://developer.android.com/reference/android/content/Context#sendOrderedBroadcast(android.content.Intent,%20java.lang.String)`.


`


final

void` `
https://developer.android.com/reference/android/content/BroadcastReceiver#clearAbortBroadcast()()
`

Clears the flag indicating that this receiver should abort the current
broadcast.


`


final

boolean` `
https://developer.android.com/reference/android/content/BroadcastReceiver#getAbortBroadcast()()
`

Returns the flag indicating whether or not this receiver should
abort the current broadcast.


`


final

boolean` `
https://developer.android.com/reference/android/content/BroadcastReceiver#getDebugUnregister()()
`

Return the last value given to `https://developer.android.com/reference/android/content/BroadcastReceiver#setDebugUnregister(boolean)`.


`


final

int` `
https://developer.android.com/reference/android/content/BroadcastReceiver#getResultCode()()
`

Retrieve the current result code, as set by the previous receiver.


`


final

https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/android/content/BroadcastReceiver#getResultData()()
`

Retrieve the current result data, as set by the previous receiver.


`


final

https://developer.android.com/reference/android/os/Bundle` `
https://developer.android.com/reference/android/content/BroadcastReceiver#getResultExtras(boolean)(boolean makeMap)
`

Retrieve the current result extra data, as set by the previous receiver.


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/android/content/BroadcastReceiver#getSentFromPackage()()
`

Returns the package name of the app that initially sent this broadcast.


`


int` `
https://developer.android.com/reference/android/content/BroadcastReceiver#getSentFromUid()()
`

Returns the uid of the app that initially sent this broadcast.


`


final

https://developer.android.com/reference/android/content/BroadcastReceiver.PendingResult` `
https://developer.android.com/reference/android/content/BroadcastReceiver#goAsync()()
`

This can be called by an application in `https://developer.android.com/reference/android/content/BroadcastReceiver#onReceive(android.content.Context,%20android.content.Intent)` to allow
it to keep the broadcast active after returning from that function.


`


final

boolean` `
https://developer.android.com/reference/android/content/BroadcastReceiver#isInitialStickyBroadcast()()
`

Returns true if the receiver is currently processing the initial
value of a sticky broadcast -- that is, the value that was last
broadcast and is currently held in the sticky cache, so this is
not directly the result of a broadcast right now.


`


final

boolean` `
https://developer.android.com/reference/android/content/BroadcastReceiver#isOrderedBroadcast()()
`

Returns true if the receiver is currently processing an ordered
broadcast.


`
abstract


void` `
https://developer.android.com/reference/android/content/BroadcastReceiver#onReceive(android.content.Context,%20android.content.Intent)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent)
`

This method is called when the BroadcastReceiver is receiving an Intent
broadcast.


`


https://developer.android.com/reference/android/os/IBinder` `
https://developer.android.com/reference/android/content/BroadcastReceiver#peekService(android.content.Context,%20android.content.Intent)(https://developer.android.com/reference/android/content/Context myContext, https://developer.android.com/reference/android/content/Intent service)
`

Provide a binder to an already-bound service.


`


final

void` `
https://developer.android.com/reference/android/content/BroadcastReceiver#setDebugUnregister(boolean)(boolean debug)
`

Control inclusion of debugging help for mismatched
calls to `https://developer.android.com/reference/android/content/Context#registerReceiver(android.content.BroadcastReceiver,%20android.content.IntentFilter)`.


`


final

void` `
https://developer.android.com/reference/android/content/BroadcastReceiver#setOrderedHint(boolean)(boolean isOrdered)
`

For internal use, sets the hint about whether this BroadcastReceiver is
running in ordered mode.


`


final

void` `
https://developer.android.com/reference/android/content/BroadcastReceiver#setResult(int,%20java.lang.String,%20android.os.Bundle)(int code, https://developer.android.com/reference/java/lang/String data, https://developer.android.com/reference/android/os/Bundle extras)
`

Change all of the result data returned from this broadcasts; only works
with broadcasts sent through
`https://developer.android.com/reference/android/content/Context#sendOrderedBroadcast(android.content.Intent,%20java.lang.String)`.


`


final

void` `
https://developer.android.com/reference/android/content/BroadcastReceiver#setResultCode(int)(int code)
`

Change the current result code of this broadcast; only works with
broadcasts sent through
`https://developer.android.com/reference/android/content/Context#sendOrderedBroadcast(android.content.Intent,%20java.lang.String)`.


`


final

void` `
https://developer.android.com/reference/android/content/BroadcastReceiver#setResultData(java.lang.String)(https://developer.android.com/reference/java/lang/String data)
`

Change the current result data of this broadcast; only works with
broadcasts sent through
`https://developer.android.com/reference/android/content/Context#sendOrderedBroadcast(android.content.Intent,%20java.lang.String)`.


`


final

void` `
https://developer.android.com/reference/android/content/BroadcastReceiver#setResultExtras(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle extras)
`

Change the current result extras of this broadcast; only works with
broadcasts sent through
`https://developer.android.com/reference/android/content/Context#sendOrderedBroadcast(android.content.Intent,%20java.lang.String)`.


From class `

https://developer.android.com/reference/java/lang/Object

` `


https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Object#clone()()
`

Creates and returns a copy of this object.


`


boolean` `
https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)
`

Indicates whether some other object is "equal to" this one.


`


void` `
https://developer.android.com/reference/java/lang/Object#finalize()()
`

Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.


`


final

https://developer.android.com/reference/java/lang/Class<?>` `
https://developer.android.com/reference/java/lang/Object#getClass()()
`

Returns the runtime class of this `Object`.


`


int` `
https://developer.android.com/reference/java/lang/Object#hashCode()()
`

Returns a hash code value for the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notify()()
`

Wakes up a single thread that is waiting on this object's
monitor.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notifyAll()()
`

Wakes up all threads that are waiting on this object's monitor.


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Object#toString()()
`

Returns a string representation of the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait()()
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*.


## Constants

### ACTION_CHOOSE_PRIVATE_KEY_ALIAS

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String ACTION_CHOOSE_PRIVATE_KEY_ALIAS
```

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

<br />

**See also:**

- `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onChoosePrivateKeyAlias(android.content.Context,%20android.content.Intent,%20int,%20android.net.Uri,%20java.lang.String)`
- `https://developer.android.com/reference/android/app/admin/DelegatedAdminReceiver#onChoosePrivateKeyAlias(android.content.Context,%20android.content.Intent,%20int,%20android.net.Uri,%20java.lang.String)`

Constant Value:

"android.app.action.CHOOSE_PRIVATE_KEY_ALIAS"


### ACTION_DEVICE_ADMIN_DISABLED

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String ACTION_DEVICE_ADMIN_DISABLED
```

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 `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onDisabled(android.content.Context,%20android.content.Intent)`. Note that
this action will be sent the receiver regardless of whether it is explicitly listed in its
intent filter.

<br />

Constant Value:

"android.app.action.DEVICE_ADMIN_DISABLED"


### ACTION_DEVICE_ADMIN_DISABLE_REQUESTED

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String ACTION_DEVICE_ADMIN_DISABLE_REQUESTED
```

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 `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#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.

<br />

Constant Value:

"android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED"


### ACTION_DEVICE_ADMIN_ENABLED

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String ACTION_DEVICE_ADMIN_ENABLED
```

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 `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onEnabled(android.content.Context,%20android.content.Intent)`. To be
supported, the receiver must also require the `https://developer.android.com/reference/android/Manifest.permission#BIND_DEVICE_ADMIN` permission so that other applications can not
abuse it.

<br />

Constant Value:

"android.app.action.DEVICE_ADMIN_ENABLED"


### ACTION_LOCK_TASK_ENTERING

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String ACTION_LOCK_TASK_ENTERING
```

Action sent to a device administrator to notify that the device is entering lock task mode.
The extra `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#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.

<br />

**See also:**

- `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#isLockTaskPermitted(java.lang.String)`

Constant Value:

"android.app.action.LOCK_TASK_ENTERING"


### ACTION_LOCK_TASK_EXITING

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String ACTION_LOCK_TASK_EXITING
```

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.

<br />

**See also:**

- `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#isLockTaskPermitted(java.lang.String)`

Constant Value:

"android.app.action.LOCK_TASK_EXITING"


### ACTION_NETWORK_LOGS_AVAILABLE

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String ACTION_NETWORK_LOGS_AVAILABLE
```

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

<br />

**See also:**

- `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onNetworkLogsAvailable(android.content.Context,%20android.content.Intent,%20long,%20int)`
- `https://developer.android.com/reference/android/app/admin/DelegatedAdminReceiver#onNetworkLogsAvailable(android.content.Context,%20android.content.Intent,%20long,%20int)`

Constant Value:

"android.app.action.NETWORK_LOGS_AVAILABLE"


### ACTION_PASSWORD_CHANGED

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String ACTION_PASSWORD_CHANGED
```

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 `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#isActivePasswordSufficient()`. You will generally handle this in `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordChanged(android.content.Context,%20android.content.Intent,%20android.os.UserHandle)`.

The calling device admin must have requested `https://developer.android.com/reference/android/app/admin/DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD` to receive this broadcast.

<br />

Constant Value:

"android.app.action.ACTION_PASSWORD_CHANGED"


### ACTION_PASSWORD_EXPIRING

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String ACTION_PASSWORD_EXPIRING
```

Action periodically sent to a device administrator when the device or profile challenge
password is expiring. You will generally handle this in `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordExpiring(android.content.Context,%20android.content.Intent,%20android.os.UserHandle)`.

The calling device admin must have requested `https://developer.android.com/reference/android/app/admin/DeviceAdminInfo#USES_POLICY_EXPIRE_PASSWORD` to receive this broadcast.

<br />

Constant Value:

"android.app.action.ACTION_PASSWORD_EXPIRING"


### ACTION_PASSWORD_FAILED

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String ACTION_PASSWORD_FAILED
```

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 `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#getCurrentFailedPasswordAttempts()`. You will generally handle this in
`https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordFailed(android.content.Context,%20android.content.Intent,%20android.os.UserHandle)`.

The calling device admin must have requested `https://developer.android.com/reference/android/app/admin/DeviceAdminInfo#USES_POLICY_WATCH_LOGIN` to receive this broadcast.

<br />

Constant Value:

"android.app.action.ACTION_PASSWORD_FAILED"


### ACTION_PASSWORD_SUCCEEDED

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String ACTION_PASSWORD_SUCCEEDED
```

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 `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordSucceeded(android.content.Context,%20android.content.Intent,%20android.os.UserHandle)`.

The calling device admin must have requested `https://developer.android.com/reference/android/app/admin/DeviceAdminInfo#USES_POLICY_WATCH_LOGIN` to receive this broadcast.

<br />

Constant Value:

"android.app.action.ACTION_PASSWORD_SUCCEEDED"


### ACTION_PROFILE_PROVISIONING_COMPLETE

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String ACTION_PROFILE_PROVISIONING_COMPLETE
```

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 `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver` component specified in the
original intent or NFC bump that started the provisioning process (see `https://developer.android.com/reference/android/app/admin/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 `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#isDeviceOwnerApp(java.lang.String)` and `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#isProfileOwnerApp(java.lang.String)`. You will generally handle this in
`https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onProfileProvisioningComplete(android.content.Context,%20android.content.Intent)`.

The intent for this action may include the following extras:

- `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE`

  <br />

  <br />

  **See also:**
  - `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#ACTION_PROVISIONING_SUCCESSFUL`

  Constant Value:

  "android.app.action.PROFILE_PROVISIONING_COMPLETE"


### ACTION_SECURITY_LOGS_AVAILABLE

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String ACTION_SECURITY_LOGS_AVAILABLE
```

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

<br />

Constant Value:

"android.app.action.SECURITY_LOGS_AVAILABLE"


### BUGREPORT_FAILURE_FAILED_COMPLETING

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int BUGREPORT_FAILURE_FAILED_COMPLETING
```

Bugreport completion process failed.

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

<br />

**See also:**

- `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#requestBugreport(android.content.ComponentName)`

Constant Value:

0
(0x00000000)


### BUGREPORT_FAILURE_FILE_NO_LONGER_AVAILABLE

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int BUGREPORT_FAILURE_FILE_NO_LONGER_AVAILABLE
```

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.

<br />

**See also:**

- `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#requestBugreport(android.content.ComponentName)`

Constant Value:

1
(0x00000001)


### DEVICE_ADMIN_META_DATA

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String DEVICE_ADMIN_META_DATA
```

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

<br />

Constant Value:

"android.app.device_admin"


### EXTRA_DISABLE_WARNING

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_DISABLE_WARNING
```

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

<br />

**See also:**

- `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_DEVICE_ADMIN_DISABLE_REQUESTED`

Constant Value:

"android.app.extra.DISABLE_WARNING"


### EXTRA_LOCK_TASK_PACKAGE

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_LOCK_TASK_PACKAGE
```

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

<br />

**See also:**

- `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_LOCK_TASK_ENTERING`

Constant Value:

"android.app.extra.LOCK_TASK_PACKAGE"


### EXTRA_TRANSFER_OWNERSHIP_ADMIN_EXTRAS_BUNDLE

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_TRANSFER_OWNERSHIP_ADMIN_EXTRAS_BUNDLE
```

A `https://developer.android.com/reference/android/os/Parcelable` extra of type `https://developer.android.com/reference/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 `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onTransferOwnershipComplete(android.content.Context,%20android.os.PersistableBundle)`. The bundle is
not changed during the ownership transfer.

<br />

**See also:**

- `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#transferOwnership(android.content.ComponentName,%20android.content.ComponentName,%20android.os.PersistableBundle)`

Constant Value:

"android.app.extra.TRANSFER_OWNERSHIP_ADMIN_EXTRAS_BUNDLE"


## Public constructors

### DeviceAdminReceiver

```
public DeviceAdminReceiver ()
```

<br />

<br />

## Public methods

### getManager

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public DevicePolicyManager getManager (Context context)
```

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

<br />

| Parameters ||
|---|---|
| `context` | `Context`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/admin/DevicePolicyManager` | This value cannot be `null`. <br /> |

### getWho

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ComponentName getWho (Context context)
```

Retrieve the ComponentName describing who this device administrator is, for use in `https://developer.android.com/reference/android/app/admin/DevicePolicyManager` APIs that require the administrator to identify itself.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/content/ComponentName` | This value cannot be `null`. <br /> |

### onBugreportFailed

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onBugreportFailed (Context context, 
                Intent intent, 
                int failureCode)
```

Called when the bugreport collection flow has failed.

This callback is only applicable to device owners.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `failureCode` | `int`: int containing failure code. One of `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#BUGREPORT_FAILURE_FAILED_COMPLETING` or `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#BUGREPORT_FAILURE_FILE_NO_LONGER_AVAILABLE` Value is one of the following: - `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#BUGREPORT_FAILURE_FAILED_COMPLETING` - `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#BUGREPORT_FAILURE_FILE_NO_LONGER_AVAILABLE` |

**See also:**

- `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#requestBugreport(android.content.ComponentName)`

### onBugreportShared

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onBugreportShared (Context context, 
                Intent intent, 
                String bugreportHash)
```

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

This callback is only applicable to device owners.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. Contains the URI of the bugreport file (with MIME type "application/vnd.android.bugreport"), that can be accessed by calling `https://developer.android.com/reference/android/content/Intent#getData()` This value cannot be `null`. <br /> |
| `bugreportHash` | `String`: SHA-256 hash of the bugreport file. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#requestBugreport(android.content.ComponentName)`

### onBugreportSharingDeclined

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onBugreportSharingDeclined (Context context, 
                Intent intent)
```

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

This callback is only applicable to device owners.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#requestBugreport(android.content.ComponentName)`

### onChoosePrivateKeyAlias

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String onChoosePrivateKeyAlias (Context context, 
                Intent intent, 
                int uid, 
                Uri uri, 
                String alias)
```

Allows this receiver to select the alias for a private key and certificate pair for
authentication. If this method returns null, the default `https://developer.android.com/reference/android/app/Activity` will be
shown that lets the user pick a private key and certificate pair. If this method returns
`https://developer.android.com/reference/android/security/KeyChain#KEY_ALIAS_SELECTION_DENIED`, the default `https://developer.android.com/reference/android/app/Activity` will
not be shown and the user will not be allowed to pick anything. And the app, that called
`https://developer.android.com/reference/android/security/KeyChain#choosePrivateKeyAlias(android.app.Activity,%20android.security.KeyChainAliasCallback,%20java.lang.String[],%20java.security.Principal[],%20android.net.Uri,%20java.lang.String)`, will receive `null` back.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `uid` | `int`: The uid of the app asking for the private key and certificate pair. <br /> |
| `uri` | `Uri`: The URI to authenticate, may be null. <br /> |
| `alias` | `String`: The alias preselected by the client, or null. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | The private key alias to return and grant access to. <br /> |

**See also:**

- `https://developer.android.com/reference/android/security/KeyChain#choosePrivateKeyAlias(android.app.Activity,%20android.security.KeyChainAliasCallback,%20java.lang.String[],%20java.security.Principal[],%20android.net.Uri,%20java.lang.String)`

### onComplianceAcknowledgementRequired

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onComplianceAcknowledgementRequired (Context context, 
                Intent intent)
```

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.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: the running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)` This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#acknowledgeDeviceCompliant()`
- `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#isComplianceAcknowledgementRequired()`
- `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#setManagedProfileMaximumTimeOff(android.content.ComponentName,%20long)`

### onDisableRequested

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public CharSequence onDisableRequested (Context context, 
                Intent intent)
```

Called when the user has asked to disable the administrator, as a result of receiving `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#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.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/CharSequence` | Return the warning message to display to the user before being disabled; if null is returned, no message is displayed. <br /> |

### onDisabled

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onDisabled (Context context, 
                Intent intent)
```

Called prior to the administrator being disabled, as a result of receiving `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_DEVICE_ADMIN_DISABLED`. Upon return, you can no longer use the protected parts of the
`https://developer.android.com/reference/android/app/admin/DevicePolicyManager` API.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |

### onEnabled

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onEnabled (Context context, 
                Intent intent)
```

Called after the administrator is first enabled, as a result of receiving `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_DEVICE_ADMIN_ENABLED`. At this point you can use `https://developer.android.com/reference/android/app/admin/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 `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#createAndManageUser(android.content.ComponentName,%20java.lang.String,%20android.content.ComponentName,%20android.os.PersistableBundle,%20int)`

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |

### onLockTaskModeEntering

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onLockTaskModeEntering (Context context, 
                Intent intent, 
                String pkg)
```

Called when a device is entering lock task mode.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `pkg` | `String`: The authorized package using lock task mode. This value cannot be `null`. <br /> |

### onLockTaskModeExiting

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onLockTaskModeExiting (Context context, 
                Intent intent)
```

Called when a device is exiting lock task mode.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |

### onNetworkLogsAvailable

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onNetworkLogsAvailable (Context context, 
                Intent intent, 
                long batchToken, 
                int networkLogsCount)
```

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 `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#setAffiliationIds(android.content.ComponentName,%20java.util.Set<java.lang.String>)`.

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.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `batchToken` | `long`: The token representing the current batch of network logs. <br /> |
| `networkLogsCount` | `int`: The total count of events in the current batch of network logs. Value is 1 or greater <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#retrieveNetworkLogs(android.content.ComponentName,%20long)`

### onOperationSafetyStateChanged

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onOperationSafetyStateChanged (Context context, 
                int reason, 
                boolean isSafe)
```

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 `https://developer.android.com/reference/android/app/admin/DevicePolicyManager` is called, so
calls to the latter could still throw a `https://developer.android.com/reference/android/app/admin/UnsafeStateException` even when this method is
called with `isSafe` as `true`

<br />

| Parameters ||
|---|---|
| `context` | `Context`: the running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)` This value cannot be `null`. <br /> |
| `reason` | `int`: the reason an operation could be unsafe. Value is one of the following: - `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#OPERATION_SAFETY_REASON_DRIVING_DISTRACTION` |
| `isSafe` | `boolean`: whether the operation is safe to be executed. <br /> |

### onPasswordChanged

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onPasswordChanged (Context context, 
                Intent intent, 
                UserHandle user)
```

Called after the user has changed their device or profile challenge password, as a result of
receiving `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_PASSWORD_CHANGED`. At this point you can use `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#getPasswordQuality(android.content.ComponentName)` to retrieve the active
password characteristics.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `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 `https://developer.android.com/reference/android/os/Process#myUserHandle()`. This value cannot be `null`. <br /> |

### onPasswordChanged

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onPasswordChanged (Context context, 
                Intent intent)
```


**This method was deprecated
in API level 26.**   

From `https://developer.android.com/reference/android/os/Build.VERSION_CODES#O`, use `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordChanged(android.content.Context,%20android.content.Intent,%20android.os.UserHandle)` instead.

Called after the user has changed their device or profile challenge password, as a result of
receiving `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_PASSWORD_CHANGED`. At this point you can use `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#getPasswordQuality(android.content.ComponentName)` to retrieve the active
password characteristics.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |

### onPasswordExpiring

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onPasswordExpiring (Context context, 
                Intent intent)
```


**This method was deprecated
in API level 26.**   

From `https://developer.android.com/reference/android/os/Build.VERSION_CODES#O`, use `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordExpiring(android.content.Context,%20android.content.Intent,%20android.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
`https://developer.android.com/reference/android/app/admin/DevicePolicyManager#getPasswordExpiration(android.content.ComponentName)`

The admin should be sure to take down any notifications it posted in response to this call
when it receives `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordChanged(android.content.Context,%20android.content.Intent)`.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |

### onPasswordExpiring

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onPasswordExpiring (Context context, 
                Intent intent, 
                UserHandle user)
```

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
`https://developer.android.com/reference/android/app/admin/DevicePolicyManager#getPasswordExpiration(android.content.ComponentName)`

The admin should be sure to take down any notifications it posted in response to this call
when it receives `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordChanged(android.content.Context,%20android.content.Intent,%20android.os.UserHandle)`.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `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 `https://developer.android.com/reference/android/os/Process#myUserHandle()`. This value cannot be `null`. <br /> |

### onPasswordFailed

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onPasswordFailed (Context context, 
                Intent intent, 
                UserHandle user)
```

Called after the user has failed at entering their device or profile challenge password, as a
result of receiving `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_PASSWORD_FAILED`. At this point you can use `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#getCurrentFailedPasswordAttempts()` to retrieve the number of failed
password attempts.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `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 `https://developer.android.com/reference/android/os/Process#myUserHandle()`. This value cannot be `null`. <br /> |

### onPasswordFailed

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onPasswordFailed (Context context, 
                Intent intent)
```


**This method was deprecated
in API level 26.**   

From `https://developer.android.com/reference/android/os/Build.VERSION_CODES#O`, use `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordFailed(android.content.Context,%20android.content.Intent,%20android.os.UserHandle)` instead.

Called after the user has failed at entering their device or profile challenge password, as a
result of receiving `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_PASSWORD_FAILED`. At this point you can use `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#getCurrentFailedPasswordAttempts()` to retrieve the number of failed
password attempts.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |

### onPasswordSucceeded

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onPasswordSucceeded (Context context, 
                Intent intent)
```


**This method was deprecated
in API level 26.**   

From `https://developer.android.com/reference/android/os/Build.VERSION_CODES#O`, use `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onPasswordSucceeded(android.content.Context,%20android.content.Intent,%20android.os.UserHandle)` instead.

Called after the user has succeeded at entering their device or profile challenge password,
as a result of receiving `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_PASSWORD_SUCCEEDED`. This will only be received the
first time they succeed after having previously failed.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |

### onPasswordSucceeded

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onPasswordSucceeded (Context context, 
                Intent intent, 
                UserHandle user)
```

Called after the user has succeeded at entering their device or profile challenge password,
as a result of receiving `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_PASSWORD_SUCCEEDED`. This will only be received the
first time they succeed after having previously failed.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `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 `https://developer.android.com/reference/android/os/Process#myUserHandle()`. This value cannot be `null`. <br /> |

### onProfileProvisioningComplete

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onProfileProvisioningComplete (Context context, 
                Intent intent)
```

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

As a prerequisite for the execution of this callback the `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver` has
to declare an intent filter for `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_PROFILE_PROVISIONING_COMPLETE`. Its component
must also be specified in the `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#EXTRA_DEVICE_ADMIN` of the `https://developer.android.com/reference/android/app/admin/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 `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#setProfileEnabled(android.content.ComponentName)`.
Typically a profile owner will enable the profile when it has finished any additional setup
such as adding an account by using the `https://developer.android.com/reference/android/accounts/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 `https://developer.android.com/reference/android/os/Build.VERSION_CODES#O`, when managed provisioning has
completed, along with this callback the activity intent `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#ACTION_PROVISIONING_SUCCESSFUL` will also be sent to the same
application.

The `Intent` may include any of the extras specified for `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_PROFILE_PROVISIONING_COMPLETE`.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |

### onReadyForUserInitialization

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onReadyForUserInitialization (Context context, 
                Intent intent)
```


**This method was deprecated
in API level 24.**   

Do not use

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

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |

### onReceive

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onReceive (Context context, 
                Intent intent)
```

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

<br />

| Parameters ||
|---|---|
| `context` | `Context`: This value cannot be `null`. <br /> |
| `intent` | `Intent`: This value cannot be `null`. <br /> |

### onSecurityLogsAvailable

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onSecurityLogsAvailable (Context context, 
                Intent intent)
```

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 `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#setAffiliationIds(android.content.ComponentName,%20java.util.Set<java.lang.String>)`

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.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#retrieveSecurityLogs(android.content.ComponentName)`

### onSystemUpdatePending

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onSystemUpdatePending (Context context, 
                Intent intent, 
                long receivedTime)
```

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 `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#getPendingSystemUpdate(android.content.ComponentName)`.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `receivedTime` | `long`: The time as given by `https://developer.android.com/reference/java/lang/System#currentTimeMillis()` indicating when the current pending update was first available. -1 if no pending update is available. <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#getPendingSystemUpdate(android.content.ComponentName)`

### onTransferAffiliatedProfileOwnershipComplete

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onTransferAffiliatedProfileOwnershipComplete (Context context, 
                UserHandle user)
```

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

<br />

<br />

| Parameters ||
|---|---|
| `context` | `Context`: the running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)` This value cannot be `null`. <br /> |
| `user` | `UserHandle`: the `https://developer.android.com/reference/android/os/UserHandle` of the affiliated user. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#transferOwnership(android.content.ComponentName,%20android.content.ComponentName,%20android.os.PersistableBundle)`

### onTransferOwnershipComplete

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onTransferOwnershipComplete (Context context, 
                PersistableBundle bundle)
```

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.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: the running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)` This value cannot be `null`. <br /> |
| `bundle` | `PersistableBundle`: the data to be passed to the new owner. This value may be `null`. <br /> |

### onUserAdded

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onUserAdded (Context context, 
                Intent intent, 
                UserHandle addedUser)
```

Called when a user or profile is created.

This callback is only applicable to device owners.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `addedUser` | `UserHandle`: The `https://developer.android.com/reference/android/os/UserHandle` of the user that has just been added. This value cannot be `null`. <br /> |

### onUserRemoved

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onUserRemoved (Context context, 
                Intent intent, 
                UserHandle removedUser)
```

Called when a user or profile is removed.

This callback is only applicable to device owners.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `removedUser` | `UserHandle`: The `https://developer.android.com/reference/android/os/UserHandle` of the user that has just been removed. This value cannot be `null`. <br /> |

### onUserStarted

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onUserStarted (Context context, 
                Intent intent, 
                UserHandle startedUser)
```

Called when a user or profile is started.

This callback is only applicable to device owners.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `startedUser` | `UserHandle`: The `https://developer.android.com/reference/android/os/UserHandle` of the user that has just been started. This value cannot be `null`. <br /> |

### onUserStopped

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onUserStopped (Context context, 
                Intent intent, 
                UserHandle stoppedUser)
```

Called when a user or profile is stopped.

This callback is only applicable to device owners.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `stoppedUser` | `UserHandle`: The `https://developer.android.com/reference/android/os/UserHandle` of the user that has just been stopped. This value cannot be `null`. <br /> |

### onUserSwitched

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onUserSwitched (Context context, 
                Intent intent, 
                UserHandle switchedUser)
```

Called when a user or profile is switched to.

This callback is only applicable to device owners.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `intent` | `Intent`: The received intent as per `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#onReceive(android.content.Context,%20android.content.Intent)`. This value cannot be `null`. <br /> |
| `switchedUser` | `UserHandle`: The `https://developer.android.com/reference/android/os/UserHandle` of the user that has just been switched to. This value cannot be `null`. <br /> |