# PolicyUpdateReceiver

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

# PolicyUpdateReceiver

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/app/admin/PolicyUpdateReceiver "View this page in Java")  

```
abstract class PolicyUpdateReceiver : BroadcastReceiver
```

|---|---|----------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                      |||
| ↳ | [android.content.BroadcastReceiver](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#)         ||
|   | ↳ | [android.app.admin.PolicyUpdateReceiver](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#) |

Base class for implementing a policy update receiver. This class provides a convenience for interpreting the raw intent actions ([ACTION_DEVICE_POLICY_SET_RESULT](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#ACTION_DEVICE_POLICY_SET_RESULT:kotlin.String)and[ACTION_DEVICE_POLICY_CHANGED](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#ACTION_DEVICE_POLICY_CHANGED:kotlin.String)) that are sent by the system.

The callback methods happen on the main thread of the process. Thus, long-running operations must be done on another thread.

When publishing your`PolicyUpdateReceiver`subclass as a receiver, it must require the[android.Manifest.permission#BIND_DEVICE_ADMIN](https://developer.android.com/reference/kotlin/android/Manifest.permission.html#BIND_DEVICE_ADMIN:kotlin.String)permission.

Admins can implement[DeviceAdminService](https://developer.android.com/reference/kotlin/android/app/admin/DeviceAdminService)to ensure they receive all policy updates (for policies they have set) via[onPolicyChanged](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicyChanged(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult))by constantly being bound to by the system. For more information see[DeviceAdminService](https://developer.android.com/reference/kotlin/android/app/admin/DeviceAdminService).

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               Constants                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ||
|----------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| static[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [ACTION_DEVICE_POLICY_CHANGED](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#ACTION_DEVICE_POLICY_CHANGED:kotlin.String) Action for a broadcast sent to admins to communicate back a change in a policy they have previously set.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| static[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [ACTION_DEVICE_POLICY_SET_RESULT](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#ACTION_DEVICE_POLICY_SET_RESULT:kotlin.String) Action for a broadcast sent to admins to communicate back the result of setting a policy in[DevicePolicyManager](https://developer.android.com/reference/kotlin/android/app/admin/DevicePolicyManager).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| static[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [EXTRA_ACCOUNT_TYPE](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#EXTRA_ACCOUNT_TYPE:kotlin.String) A string extra holding the account type this policy applies to, (see[PolicyUpdateReceiver.onPolicyChanged](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicyChanged(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult))and[PolicyUpdateReceiver.onPolicySetResult](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicySetResult(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult)))                                                                                                             |
| static[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [EXTRA_INTENT_FILTER](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#EXTRA_INTENT_FILTER:kotlin.String) An[android.content.IntentFilter](https://developer.android.com/reference/kotlin/android/content/IntentFilter.html#)extra holding the intent filter the policy relates to, (see[PolicyUpdateReceiver.onPolicyChanged](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicyChanged(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult))and[PolicyUpdateReceiver.onPolicySetResult](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicySetResult(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult))) |
| static[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [EXTRA_PACKAGE_NAME](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#EXTRA_PACKAGE_NAME:kotlin.String) A string extra holding the package name the policy applies to, (see[PolicyUpdateReceiver.onPolicyChanged](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicyChanged(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult))and[PolicyUpdateReceiver.onPolicySetResult](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicySetResult(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult)))                                                                                                              |
| static[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [EXTRA_PERMISSION_NAME](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#EXTRA_PERMISSION_NAME:kotlin.String) A string extra holding the permission name the policy applies to, (see[PolicyUpdateReceiver.onPolicyChanged](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicyChanged(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult))and[PolicyUpdateReceiver.onPolicySetResult](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicySetResult(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult)))                                                                                                     |

|                                                                Public constructors                                                                 ||
|-------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [PolicyUpdateReceiver](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#PolicyUpdateReceiver())`()` <br /> |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ||
|----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onPolicyChanged](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicyChanged(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult))`(`context:` `[Context](https://developer.android.com/reference/kotlin/android/content/Context.html#)`, `policyIdentifier:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `additionalPolicyParams:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)`, `targetUser:` `[TargetUser](https://developer.android.com/reference/kotlin/android/app/admin/TargetUser)`, `policyUpdateResult:` `[PolicyUpdateResult](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateResult)`)` Callback triggered when a policy previously set by the admin has changed.                                                                                                                                                                            |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onPolicySetResult](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicySetResult(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult))`(`context:` `[Context](https://developer.android.com/reference/kotlin/android/content/Context.html#)`, `policyIdentifier:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `additionalPolicyParams:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)`, `targetUser:` `[TargetUser](https://developer.android.com/reference/kotlin/android/app/admin/TargetUser)`, `policyUpdateResult:` `[PolicyUpdateResult](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateResult)`)` Callback triggered after an admin has set a policy using one of the APIs in[DevicePolicyManager](https://developer.android.com/reference/kotlin/android/app/admin/DevicePolicyManager)to notify the admin whether it has been successful or not. |

| Inherited functions ||
|---|---|
| From class[BroadcastReceiver](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#) |------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                                             | [abortBroadcast](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#abortBroadcast())`()` <br /> Sets the flag indicating that this receiver should abort the current broadcast; only works with broadcasts sent through[Context.sendOrderedBroadcast](https://developer.android.com/reference/kotlin/android/content/Context.html#sendOrderedBroadcast(android.content.Intent,%20kotlin.String)). This will prevent any other broadcast receivers from receiving the broadcast. It will still call[onReceive](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#onReceive(android.content.Context,%20android.content.Intent))of the BroadcastReceiver that the caller of[Context.sendOrderedBroadcast](https://developer.android.com/reference/kotlin/android/content/Context.html#sendOrderedBroadcast(android.content.Intent,%20kotlin.String))passed in. **This method does not work with non-ordered broadcasts such as those sent with[Context.sendBroadcast](https://developer.android.com/reference/kotlin/android/content/Context.html#sendBroadcast(android.content.Intent))** <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                                             | [clearAbortBroadcast](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#clearAbortBroadcast())`()` <br /> Clears the flag indicating that this receiver should abort the current broadcast. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                                       | [getAbortBroadcast](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#getAbortBroadcast())`()` <br /> Returns the flag indicating whether or not this receiver should abort the current broadcast. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                                       | [getDebugUnregister](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#getDebugUnregister())`()` <br /> Return the last value given to[setDebugUnregister](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#setDebugUnregister(kotlin.Boolean)). <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                                                               | [getResultCode](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#getResultCode())`()` <br /> Retrieve the current result code, as set by the previous receiver. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!                                                        | [getResultData](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#getResultData())`()` <br /> Retrieve the current result data, as set by the previous receiver. Often this is null. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | | [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)!                                                        | [getResultExtras](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#getResultExtras(kotlin.Boolean))`(`makeMap:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` <br /> Retrieve the current result extra data, as set by the previous receiver. Any changes you make to the returned Map will be propagated to the next receiver. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?                                                        | [getSentFromPackage](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#getSentFromPackage())`()` <br /> Returns the package name of the app that initially sent this broadcast. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                                                               | [getSentFromUid](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#getSentFromUid())`()` <br /> Returns the uid of the app that initially sent this broadcast. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | | [BroadcastReceiver.PendingResult](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.PendingResult.html#)! | [goAsync](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#goAsync())`()` <br /> This can be called by an application in[onReceive](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#onReceive(android.content.Context,%20android.content.Intent))to allow it to keep the broadcast active after returning from that function. This does*not*change the expectation of being relatively responsive to the broadcast, but does allow the implementation to move work related to it over to another thread to avoid glitching the main UI thread due to disk IO. As a general rule, broadcast receivers are allowed to run for up to 10 seconds before the system will consider them non-responsive and ANR the app. Since these usually execute on the app's main thread, they are already bound by the \~5 second time limit of various operations that can happen there (not to mention just avoiding UI jank), so the receive limit is generally not of concern. However, once you use`goAsync`, though able to be off the main thread, the broadcast execution limit still applies, and that includes the time spent between calling this method and ultimately[PendingResult.finish()](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.PendingResult.html#finish()). If you are taking advantage of this method to have more time to execute, it is useful to know that the available time can be longer in certain situations. In particular, if the broadcast you are receiving is not a foreground broadcast (that is, the sender has not used[Intent.FLAG_RECEIVER_FOREGROUND](https://developer.android.com/reference/kotlin/android/content/Intent.html#FLAG_RECEIVER_FOREGROUND:kotlin.Int)), then more time is allowed for the receivers to run, allowing them to execute for 30 seconds or even a bit more. This is something that receivers should rarely take advantage of (long work should be punted to another system facility such as[android.app.job.JobScheduler](https://developer.android.com/reference/kotlin/android/app/job/JobScheduler.html#),[android.app.Service](https://developer.android.com/reference/kotlin/android/app/Service.html#), or see especially androidx.core.app.JobIntentService), but can be useful in certain rare cases where it is necessary to do some work as soon as the broadcast is delivered. Keep in mind that the work you do here will block further broadcasts until it completes, so taking advantage of this at all excessively can be counter-productive and cause later events to be received more slowly. <br /> | | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                                       | [isInitialStickyBroadcast](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#isInitialStickyBroadcast())`()` <br /> 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. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                                       | [isOrderedBroadcast](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#isOrderedBroadcast())`()` <br /> Returns true if the receiver is currently processing an ordered broadcast. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | | [IBinder](https://developer.android.com/reference/kotlin/android/os/IBinder.html#)!                                                      | [peekService](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#peekService(android.content.Context,%20android.content.Intent))`(`myContext:` `[Context](https://developer.android.com/reference/kotlin/android/content/Context.html#)!`, `service:` `[Intent](https://developer.android.com/reference/kotlin/android/content/Intent.html#)!`)` <br /> Provide a binder to an already-bound service. This method is synchronous and will not start the target service if it is not present, so it is safe to call from[onReceive](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#onReceive(android.content.Context,%20android.content.Intent)). For peekService() to return a non null[android.os.IBinder](https://developer.android.com/reference/kotlin/android/os/IBinder.html#)interface the service must have published it before. In other words some component must have called[android.content.Context#bindService(Intent, ServiceConnection, int)](https://developer.android.com/reference/kotlin/android/content/Context.html#bindService(android.content.Intent,%20android.content.ServiceConnection,%20kotlin.Int))on it. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                                             | [setDebugUnregister](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#setDebugUnregister(kotlin.Boolean))`(`debug:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` <br /> Control inclusion of debugging help for mismatched calls to[Context.registerReceiver()](https://developer.android.com/reference/kotlin/android/content/Context.html#registerReceiver(android.content.BroadcastReceiver,%20android.content.IntentFilter)). If called with true, before given to registerReceiver(), then the callstack of the following[Context.unregisterReceiver()](https://developer.android.com/reference/kotlin/android/content/Context.html#unregisterReceiver(android.content.BroadcastReceiver))call is retained, to be printed if a later incorrect unregister call is made. Note that doing this requires retaining information about the BroadcastReceiver for the lifetime of the app, resulting in a leak -- this should only be used for debugging. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                                             | [setOrderedHint](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#setOrderedHint(kotlin.Boolean))`(`isOrdered:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` <br /> For internal use, sets the hint about whether this BroadcastReceiver is running in ordered mode. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                                             | [setResult](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#setResult(kotlin.Int,%20kotlin.String,%20android.os.Bundle))`(`code:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `data:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `extras:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)!`)` <br /> Change all of the result data returned from this broadcasts; only works with broadcasts sent through[Context.sendOrderedBroadcast](https://developer.android.com/reference/kotlin/android/content/Context.html#sendOrderedBroadcast(android.content.Intent,%20kotlin.String)). All current result data is replaced by the value given to this method. **This method does not work with non-ordered broadcasts such as those sent with[Context.sendBroadcast](https://developer.android.com/reference/kotlin/android/content/Context.html#sendBroadcast(android.content.Intent))** <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                                             | [setResultCode](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#setResultCode(kotlin.Int))`(`code:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` <br /> Change the current result code of this broadcast; only works with broadcasts sent through[Context.sendOrderedBroadcast](https://developer.android.com/reference/kotlin/android/content/Context.html#sendOrderedBroadcast(android.content.Intent,%20kotlin.String)). Often uses the Activity[android.app.Activity#RESULT_CANCELED](https://developer.android.com/reference/kotlin/android/app/Activity.html#RESULT_CANCELED:kotlin.Int)and[android.app.Activity#RESULT_OK](https://developer.android.com/reference/kotlin/android/app/Activity.html#RESULT_OK:kotlin.Int)constants, though the actual meaning of this value is ultimately up to the broadcaster. This method does not work with non-ordered broadcasts such as those sent with[Context.sendBroadcast](https://developer.android.com/reference/kotlin/android/content/Context.html#sendBroadcast(android.content.Intent)) <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                                             | [setResultData](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#setResultData(kotlin.String))`(`data:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` <br /> Change the current result data of this broadcast; only works with broadcasts sent through[Context.sendOrderedBroadcast](https://developer.android.com/reference/kotlin/android/content/Context.html#sendOrderedBroadcast(android.content.Intent,%20kotlin.String)). This is an arbitrary string whose interpretation is up to the broadcaster. **This method does not work with non-ordered broadcasts such as those sent with[Context.sendBroadcast](https://developer.android.com/reference/kotlin/android/content/Context.html#sendBroadcast(android.content.Intent))** <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                                             | [setResultExtras](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#setResultExtras(android.os.Bundle))`(`extras:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)!`)` <br /> Change the current result extras of this broadcast; only works with broadcasts sent through[Context.sendOrderedBroadcast](https://developer.android.com/reference/kotlin/android/content/Context.html#sendOrderedBroadcast(android.content.Intent,%20kotlin.String)). This is a Bundle holding arbitrary data, whose interpretation is up to the broadcaster. Can be set to null. Calling this method completely replaces the current map (if any). **This method does not work with non-ordered broadcasts such as those sent with[Context.sendBroadcast](https://developer.android.com/reference/kotlin/android/content/Context.html#sendBroadcast(android.content.Intent))** <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | ||

## Constants

### ACTION_DEVICE_POLICY_CHANGED

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

```
static val ACTION_DEVICE_POLICY_CHANGED: String
```

Action for a broadcast sent to admins to communicate back a change in a policy they have previously set.

Admins wishing to receive these updates should include this action in the intent filter for their receiver in the manifest, the receiver must be protected by[android.Manifest.permission#BIND_DEVICE_ADMIN](https://developer.android.com/reference/kotlin/android/Manifest.permission.html#BIND_DEVICE_ADMIN:kotlin.String)to ensure that only the system can send updates.

Admins shouldn't implement[onReceive](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#)and should instead implement[onPolicyChanged](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicyChanged(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult)).  

    Value: "android.app.admin.action.DEVICE_POLICY_CHANGED"

### ACTION_DEVICE_POLICY_SET_RESULT

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

```
static val ACTION_DEVICE_POLICY_SET_RESULT: String
```

Action for a broadcast sent to admins to communicate back the result of setting a policy in[DevicePolicyManager](https://developer.android.com/reference/kotlin/android/app/admin/DevicePolicyManager).

Admins wishing to receive these updates (via[onPolicySetResult](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicySetResult(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult))) should include this action in the intent filter for their receiver in the manifest, the receiver must be protected by[android.Manifest.permission#BIND_DEVICE_ADMIN](https://developer.android.com/reference/kotlin/android/Manifest.permission.html#BIND_DEVICE_ADMIN:kotlin.String)to ensure that only the system can send updates.

Admins shouldn't implement[onReceive](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#)and should instead implement[onPolicySetResult](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicySetResult(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult)).  

    Value: "android.app.admin.action.DEVICE_POLICY_SET_RESULT"

### EXTRA_ACCOUNT_TYPE

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

```
static val EXTRA_ACCOUNT_TYPE: String
```

A string extra holding the account type this policy applies to, (see[PolicyUpdateReceiver.onPolicyChanged](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicyChanged(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult))and[PolicyUpdateReceiver.onPolicySetResult](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicySetResult(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult)))  

    Value: "android.app.admin.extra.ACCOUNT_TYPE"

### EXTRA_INTENT_FILTER

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

```
static val EXTRA_INTENT_FILTER: String
```

An[android.content.IntentFilter](https://developer.android.com/reference/kotlin/android/content/IntentFilter.html#)extra holding the intent filter the policy relates to, (see[PolicyUpdateReceiver.onPolicyChanged](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicyChanged(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult))and[PolicyUpdateReceiver.onPolicySetResult](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicySetResult(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult)))  

    Value: "android.app.admin.extra.INTENT_FILTER"

### EXTRA_PACKAGE_NAME

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

```
static val EXTRA_PACKAGE_NAME: String
```

A string extra holding the package name the policy applies to, (see[PolicyUpdateReceiver.onPolicyChanged](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicyChanged(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult))and[PolicyUpdateReceiver.onPolicySetResult](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicySetResult(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult)))  

    Value: "android.app.admin.extra.PACKAGE_NAME"

### EXTRA_PERMISSION_NAME

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

```
static val EXTRA_PERMISSION_NAME: String
```

A string extra holding the permission name the policy applies to, (see[PolicyUpdateReceiver.onPolicyChanged](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicyChanged(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult))and[PolicyUpdateReceiver.onPolicySetResult](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#onPolicySetResult(android.content.Context,%20kotlin.String,%20android.os.Bundle,%20android.app.admin.TargetUser,%20android.app.admin.PolicyUpdateResult)))  

    Value: "android.app.admin.extra.PERMISSION_NAME"

## Public constructors

### PolicyUpdateReceiver

```
PolicyUpdateReceiver()
```

## Public methods

### onPolicyChanged

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

```
open fun onPolicyChanged(
    context: Context, 
    policyIdentifier: String, 
    additionalPolicyParams: Bundle, 
    targetUser: TargetUser, 
    policyUpdateResult: PolicyUpdateResult
): Unit
```

Callback triggered when a policy previously set by the admin has changed.

Admins wishing to receive this callback should include[PolicyUpdateReceiver.ACTION_DEVICE_POLICY_CHANGED](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#ACTION_DEVICE_POLICY_CHANGED:kotlin.String)in the intent filter for their receiver in the manifest, the receiver must be protected by[android.Manifest.permission#BIND_DEVICE_ADMIN](https://developer.android.com/reference/kotlin/android/Manifest.permission.html#BIND_DEVICE_ADMIN:kotlin.String)to ensure that only the system can send updates.

|                                                                                                                                                                                                                                                                                                                                                          Parameters                                                                                                                                                                                                                                                                                                                                                           ||
|--------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `context`                | [Context](https://developer.android.com/reference/kotlin/android/content/Context.html#):the running context as per[onReceive](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#)This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `policyIdentifier`       | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):Key to identify which policy this callback relates to. This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `additionalPolicyParams` | [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#):Bundle containing additional params that may be required to identify some of the policy (e.g.[PolicyUpdateReceiver.EXTRA_PACKAGE_NAME](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#EXTRA_PACKAGE_NAME:kotlin.String)and[PolicyUpdateReceiver.EXTRA_PERMISSION_NAME](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#EXTRA_PERMISSION_NAME:kotlin.String)). Each policy will document the required additional params if needed. This value cannot be`null`.                                                                         |
| `targetUser`             | [TargetUser](https://developer.android.com/reference/kotlin/android/app/admin/TargetUser):The[TargetUser](https://developer.android.com/reference/kotlin/android/app/admin/TargetUser)which this policy relates to. This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `policyUpdateResult`     | [PolicyUpdateResult](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateResult):Indicates the reason the policy value has changed (e.g.[PolicyUpdateResult.RESULT_POLICY_SET](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateResult#RESULT_POLICY_SET:kotlin.Int)if the policy has changed to the value set by the admin,[PolicyUpdateResult.RESULT_FAILURE_CONFLICTING_ADMIN_POLICY](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateResult#RESULT_FAILURE_CONFLICTING_ADMIN_POLICY:kotlin.Int)if the policy has changed because another admin has set a conflicting policy, etc) This value cannot be`null`. |

### onPolicySetResult

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

```
open fun onPolicySetResult(
    context: Context, 
    policyIdentifier: String, 
    additionalPolicyParams: Bundle, 
    targetUser: TargetUser, 
    policyUpdateResult: PolicyUpdateResult
): Unit
```

Callback triggered after an admin has set a policy using one of the APIs in[DevicePolicyManager](https://developer.android.com/reference/kotlin/android/app/admin/DevicePolicyManager)to notify the admin whether it has been successful or not.

Admins wishing to receive this callback should include[PolicyUpdateReceiver.ACTION_DEVICE_POLICY_SET_RESULT](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#ACTION_DEVICE_POLICY_SET_RESULT:kotlin.String)in the intent filter for their receiver in the manifest, the receiver must be protected by[android.Manifest.permission#BIND_DEVICE_ADMIN](https://developer.android.com/reference/kotlin/android/Manifest.permission.html#BIND_DEVICE_ADMIN:kotlin.String)to ensure that only the system can send updates.

|                                                                                                                                                                                                                                                                                                                      Parameters                                                                                                                                                                                                                                                                                                                       ||
|--------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `context`                | [Context](https://developer.android.com/reference/kotlin/android/content/Context.html#):the running context as per[onReceive](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#)This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                            |
| `policyIdentifier`       | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):Key to identify which policy this callback relates to. This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `additionalPolicyParams` | [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#):Bundle containing additional params that may be required to identify some of the policy (e.g.[PolicyUpdateReceiver.EXTRA_PACKAGE_NAME](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#EXTRA_PACKAGE_NAME:kotlin.String)and[PolicyUpdateReceiver.EXTRA_PERMISSION_NAME](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateReceiver#EXTRA_PERMISSION_NAME:kotlin.String)). Each policy will document the required additional params if needed. This value cannot be`null`. |
| `targetUser`             | [TargetUser](https://developer.android.com/reference/kotlin/android/app/admin/TargetUser):The[TargetUser](https://developer.android.com/reference/kotlin/android/app/admin/TargetUser)which this policy relates to. This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                             |
| `policyUpdateResult`     | [PolicyUpdateResult](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateResult):Indicates whether the policy has been set successfully ([PolicyUpdateResult.RESULT_POLICY_SET](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateResult#RESULT_POLICY_SET:kotlin.Int)) or the reason it failed to apply (e.g.[PolicyUpdateResult.RESULT_FAILURE_CONFLICTING_ADMIN_POLICY](https://developer.android.com/reference/kotlin/android/app/admin/PolicyUpdateResult#RESULT_FAILURE_CONFLICTING_ADMIN_POLICY:kotlin.Int), etc). This value cannot be`null`.                   |