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

# RestrictionsReceiver

*** ** * ** ***

` public abstract class RestrictionsReceiver `   
` ` ` 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.service.restrictions.RestrictionsReceiver |

<br />

*** ** * ** ***

Abstract implementation of a Restrictions Provider BroadcastReceiver. To implement a Restrictions Provider, extend from this class and implement the abstract methods. Export this receiver in the manifest. A profile owner device admin can then register this component as a Restrictions Provider using `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#setRestrictionsProvider(android.content.ComponentName,%20android.content.ComponentName)`.

The function of a Restrictions Provider is to transport permission requests from apps on this device to an administrator (most likely on a remote device or computer) and deliver back responses. The response should be sent back to the app via `https://developer.android.com/reference/android/content/RestrictionsManager#notifyPermissionResponse(java.lang.String,%20android.os.PersistableBundle)`.
**See also:**

- `https://developer.android.com/reference/android/content/RestrictionsManager`

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/service/restrictions/RestrictionsReceiver#RestrictionsReceiver()() ` |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/service/restrictions/RestrictionsReceiver#onReceive(android.content.Context,%20android.content.Intent)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/content/Intent intent) ` Intercept standard Restrictions Provider broadcasts. |
| ` abstract void` | ` https://developer.android.com/reference/android/service/restrictions/RestrictionsReceiver#onRequestPermission(android.content.Context,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20android.os.PersistableBundle)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/java/lang/String packageName, https://developer.android.com/reference/java/lang/String requestType, https://developer.android.com/reference/java/lang/String requestId, https://developer.android.com/reference/android/os/PersistableBundle request) ` An asynchronous permission request made by an application for an operation that requires authorization by a local or remote administrator other than the user. |

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

### RestrictionsReceiver

```
public RestrictionsReceiver ()
```

<br />

<br />

## Public methods

### onReceive

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

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

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

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The Context in which the receiver is running. <br /> |
| `intent` | `Intent`: The Intent being received. <br /> |

### onRequestPermission

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

```
public abstract void onRequestPermission (Context context, 
                String packageName, 
                String requestType, 
                String requestId, 
                PersistableBundle request)
```

An asynchronous permission request made by an application for an operation that requires authorization by a local or remote administrator other than the user. The Restrictions Provider should transfer the request to the administrator and deliver back a response, when available. The calling application is aware that the response could take an indefinite amount of time.

If the request bundle contains the key `https://developer.android.com/reference/android/content/RestrictionsManager#REQUEST_KEY_NEW_REQUEST`, then a new request must be sent. Otherwise the provider can look up any previous response to the same requestId and return the cached response.

<br />

| Parameters ||
|---|---|
| `context` | `Context` <br /> |
| `packageName` | `String`: the application requesting permission. <br /> |
| `requestType` | `String`: the type of request, which determines the content and presentation of the request data. <br /> |
| `requestId` | `String` <br /> |
| `request` | `PersistableBundle`: the request data bundle containing at a minimum a request id. <br /> |

**See also:**

- `https://developer.android.com/reference/android/content/RestrictionsManager#REQUEST_TYPE_APPROVAL`
- `https://developer.android.com/reference/android/content/RestrictionsManager#REQUEST_KEY_ID`