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

# DelegatedAdminReceiver

*** ** * ** ***


`
public


class
DelegatedAdminReceiver
`


`


`

`

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.DelegatedAdminReceiver |

<br />

*** ** * ** ***

Base class for delegated apps to handle callbacks related to their delegated capabilities.

Delegated apps are apps that receive additional capabilities from the profile owner or device
owner apps. Some of these capabilities involve the framework calling into the apps. To receive
these callbacks, delegated apps should subclass this class and override the appropriate methods
here. The subclassed receiver needs to be published in the app's manifest, with appropriate
intent filters to mark which callbacks the receiver is interested in. An app can have multiple
receivers as long as they listen for disjoint set of callbacks. For the manifest definitions, it
must be protected by the `https://developer.android.com/reference/android/Manifest.permission#BIND_DEVICE_ADMIN` permission to
ensure only the system can trigger these callbacks.

The callback methods 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
onReceive function, such long-running operations should probably be done in a `https://developer.android.com/reference/android/app/Service`.
**See also:**

- `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#setDelegatedScopes(android.content.ComponentName,%20java.lang.String,%20java.util.List<java.lang.String>)`
- `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver`

## Summary

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

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/java/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)(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/DelegatedAdminReceiver#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. |
| ` final void` | ` https://developer.android.com/reference/android/app/admin/DelegatedAdminReceiver#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 delegated device administrator broadcasts. |
| ` void` | ` https://developer.android.com/reference/android/app/admin/DelegatedAdminReceiver#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 each time a new batch of security logs can be retrieved. |

### 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*.


## Public constructors

### DelegatedAdminReceiver

```
public DelegatedAdminReceiver ()
```

<br />

<br />

## Public methods

### onChoosePrivateKeyAlias

Added in [API level 29](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.

This callback is only applicable if the delegated app has `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#DELEGATION_CERT_SELECTION` capability. Additionally, it must declare an
intent filter for `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_CHOOSE_PRIVATE_KEY_ALIAS` in the
receiver's manifest in order to receive this callback. The default implementation simply
throws `https://developer.android.com/reference/java/lang/UnsupportedOperationException`.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The running context as per `https://developer.android.com/reference/android/app/admin/DelegatedAdminReceiver#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/DelegatedAdminReceiver#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)`

### onNetworkLogsAvailable

Added in [API level 29](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 if the delegated app has `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#DELEGATION_NETWORK_LOGGING` capability. Additionally, it must declare an
intent filter for `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_NETWORK_LOGS_AVAILABLE` in the receiver's
manifest in order to receive this callback. The default implementation simply throws `https://developer.android.com/reference/java/lang/UnsupportedOperationException`.

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/DelegatedAdminReceiver#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/DelegatedAdminReceiver#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)`

### onReceive

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

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

Intercept delegated device administrator broadcasts. Implementations should not override this
method; implement the convenience callbacks for each action instead.

<br />

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

### onSecurityLogsAvailable

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

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

Called each time a new batch of security logs can be retrieved. This callback method will
only ever be called when security logging is enabled. The logs can only be retrieved while
security 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 security logging is enabled). It will also no longer be
possible to retrieve the security logs. 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 if the delegated app has `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#DELEGATION_SECURITY_LOGGING` capability. Additionally, it must declare an
intent filter for `https://developer.android.com/reference/android/app/admin/DeviceAdminReceiver#ACTION_SECURITY_LOGS_AVAILABLE` in the
receiver's manifest in order to receive this callback. The default implementation simply
throws `https://developer.android.com/reference/java/lang/UnsupportedOperationException`.

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/DelegatedAdminReceiver#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/DelegatedAdminReceiver#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)`