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

# PermissionRequest

*** ** * ** ***

` public abstract class PermissionRequest `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.webkit.PermissionRequest |

<br />

*** ** * ** ***

This class defines a permission request and is used when web content requests access to protected resources. The permission request related events are delivered via `https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequest(android.webkit.PermissionRequest)` and `https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequestCanceled(android.webkit.PermissionRequest)`. Either `https://developer.android.com/reference/android/webkit/PermissionRequest#grant(java.lang.String[])` or `https://developer.android.com/reference/android/webkit/PermissionRequest#deny()` must be called in UI thread to respond to the request. New protected resources whose names are not defined here may be requested in future versions of WebView, even when running on an older Android release. To avoid unintentionally granting requests for new permissions, you should pass the specific permissions you intend to grant to `https://developer.android.com/reference/android/webkit/PermissionRequest#grant(java.lang.String[])`, and avoid writing code like this example:

```
permissionRequest.grant(permissionRequest.getResources())  // This is wrong!!!
```
See the WebView's release notes for information about new protected resources.

<br />

## Summary

| ### Constants ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_AUDIO_CAPTURE` Resource belongs to audio capture device, like microphone. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_MIDI_SYSEX` Resource will allow sysex messages to be sent to or received from MIDI devices. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_PROTECTED_MEDIA_ID` Resource belongs to protected media identifier. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_VIDEO_CAPTURE` Resource belongs to video capture device, like camera. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/webkit/PermissionRequest#PermissionRequest()() ` |

| ### Public methods ||
|---|---|
| ` abstract void` | ` https://developer.android.com/reference/android/webkit/PermissionRequest#deny()() ` Call this method to deny the request. |
| ` abstract https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/webkit/PermissionRequest#getOrigin()() ` Call this method to get the origin of the web page which is trying to access the restricted resources. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/webkit/PermissionRequest#getResources()() ` Call this method to get the resources the web page is trying to access. |
| ` abstract void` | ` https://developer.android.com/reference/android/webkit/PermissionRequest#grant(java.lang.String[])(https://developer.android.com/reference/java/lang/String resources) ` Call this method to grant origin the permission to access the given resources. |

### Inherited methods

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

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

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

## Constants

### RESOURCE_AUDIO_CAPTURE

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

```
public static final String RESOURCE_AUDIO_CAPTURE
```

Resource belongs to audio capture device, like microphone.

<br />

Constant Value: "android.webkit.resource.AUDIO_CAPTURE"

### RESOURCE_MIDI_SYSEX

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

```
public static final String RESOURCE_MIDI_SYSEX
```

Resource will allow sysex messages to be sent to or received from MIDI devices. These messages are privileged operations, e.g. modifying sound libraries and sampling data, or even updating the MIDI device's firmware. Permission may be requested for this resource in API levels 21 and above, if the Android device has been updated to WebView 45 or above.

<br />

Constant Value: "android.webkit.resource.MIDI_SYSEX"

### RESOURCE_PROTECTED_MEDIA_ID

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

```
public static final String RESOURCE_PROTECTED_MEDIA_ID
```

Resource belongs to protected media identifier. After the user grants this resource, the origin can use EME APIs to generate the license requests.

<br />

Constant Value: "android.webkit.resource.PROTECTED_MEDIA_ID"

### RESOURCE_VIDEO_CAPTURE

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

```
public static final String RESOURCE_VIDEO_CAPTURE
```

Resource belongs to video capture device, like camera.

<br />

Constant Value: "android.webkit.resource.VIDEO_CAPTURE"

## Public constructors

### PermissionRequest

```
public PermissionRequest ()
```

<br />

<br />

## Public methods

### deny

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

```
public abstract void deny ()
```

Call this method to deny the request.

<br />

### getOrigin

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

```
public abstract Uri getOrigin ()
```

Call this method to get the origin of the web page which is trying to access the restricted resources.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | the origin of web content which attempt to access the restricted resources. <br /> |

### getResources

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

```
public abstract String[] getResources ()
```

Call this method to get the resources the web page is trying to access.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the array of resources the web content wants to access. <br /> |

### grant

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

```
public abstract void grant (String[] resources)
```

Call this method to grant origin the permission to access the given resources. The granted permission is only valid for this WebView.

<br />

| Parameters ||
|---|---|
| `resources` | `String`: the resources granted to be accessed by origin, to grant request, the requested resources returned by `https://developer.android.com/reference/android/webkit/PermissionRequest#getResources()` must be equals or a subset of granted resources. This parameter is designed to avoid granting permission by accident especially when new resources are requested by web content. <br /> |