Stay organized with collections
Save and categorize content based on your preferences.
WebResourceRequest
public
interface
WebResourceRequest
android.webkit.WebResourceRequest
|
Encompasses parameters to the WebViewClient.shouldInterceptRequest
method.
Summary
Public methods |
abstract
String
|
getMethod()
Gets the method associated with the request, for example "GET".
|
abstract
Map<String, String>
|
getRequestHeaders()
Gets the headers associated with the request.
|
abstract
Uri
|
getUrl()
Gets the URL for which the resource request was made.
|
abstract
boolean
|
hasGesture()
Gets whether a gesture (such as a click) was associated with the request.
|
abstract
boolean
|
isForMainFrame()
Gets whether the request was made in order to fetch the main frame's document.
|
abstract
boolean
|
isRedirect()
Gets whether the request was a result of a server-side redirect.
|
Public methods
getMethod
public abstract String getMethod ()
Gets the method associated with the request, for example "GET".
Returns |
String |
the method associated with the request. |
public abstract Map<String, String> getRequestHeaders ()
Gets the headers associated with the request. These are represented as a mapping of header
name to header value.
getUrl
public abstract Uri getUrl ()
Gets the URL for which the resource request was made.
Returns |
Uri |
the URL for which the resource request was made. |
hasGesture
public abstract boolean hasGesture ()
Gets whether a gesture (such as a click) was associated with the request.
For security reasons in certain situations this method may return false
even though
the sequence of events which caused the request to be created was initiated by a user
gesture.
Returns |
boolean |
whether a gesture was associated with the request. |
isForMainFrame
public abstract boolean isForMainFrame ()
Gets whether the request was made in order to fetch the main frame's document.
Returns |
boolean |
whether the request was made for the main frame document. Will be
false for subresources or iframes, for example. |
isRedirect
public abstract boolean isRedirect ()
Gets whether the request was a result of a server-side redirect.
Returns |
boolean |
whether the request was a result of a server-side redirect. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# WebResourceRequest\n\nAdded in [API level 21](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nWebResourceRequest\n==================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/webkit/WebResourceRequest \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\n\n\ninterface\nWebResourceRequest\n`\n\n\n`\n\n\n`\n\n|-----------------------------------|\n| android.webkit.WebResourceRequest |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nEncompasses parameters to the [WebViewClient.shouldInterceptRequest](/reference/android/webkit/WebViewClient#shouldInterceptRequest(android.webkit.WebView,%20android.webkit.WebResourceRequest)) method.\n\nSummary\n-------\n\n| ### Public methods ||\n|---------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract `[String](/reference/java/lang/String) | ` `[getMethod](/reference/android/webkit/WebResourceRequest#getMethod())`() ` Gets the method associated with the request, for example \"GET\". |\n| ` abstract `[Map](/reference/java/util/Map)`\u003c`[String](/reference/java/lang/String)`, `[String](/reference/java/lang/String)`\u003e` | ` `[getRequestHeaders](/reference/android/webkit/WebResourceRequest#getRequestHeaders())`() ` Gets the headers associated with the request. |\n| ` abstract `[Uri](/reference/android/net/Uri) | ` `[getUrl](/reference/android/webkit/WebResourceRequest#getUrl())`() ` Gets the URL for which the resource request was made. |\n| ` abstract boolean` | ` `[hasGesture](/reference/android/webkit/WebResourceRequest#hasGesture())`() ` Gets whether a gesture (such as a click) was associated with the request. |\n| ` abstract boolean` | ` `[isForMainFrame](/reference/android/webkit/WebResourceRequest#isForMainFrame())`() ` Gets whether the request was made in order to fetch the main frame's document. |\n| ` abstract boolean` | ` `[isRedirect](/reference/android/webkit/WebResourceRequest#isRedirect())`() ` Gets whether the request was a result of a server-side redirect. |\n\nPublic methods\n--------------\n\n### getMethod\n\nAdded in [API level 21](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract String getMethod ()\n```\n\nGets the method associated with the request, for example \"GET\".\n\n\u003cbr /\u003e\n\n| Returns ||\n|---------------------------------------|------------------------------------------------|\n| [String](/reference/java/lang/String) | the method associated with the request. \u003cbr /\u003e |\n\n### getRequestHeaders\n\nAdded in [API level 21](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract Map\u003cString, String\u003e getRequestHeaders ()\n```\n\nGets the headers associated with the request. These are represented as a mapping of header\nname to header value.\n\n\u003cbr /\u003e\n\n| Returns ||\n|---------------------------------------------------------------------------------------------------------------------|-------------------------------------------------|\n| [Map](/reference/java/util/Map)`\u003c`[String](/reference/java/lang/String)`, `[String](/reference/java/lang/String)`\u003e` | the headers associated with the request. \u003cbr /\u003e |\n\n### getUrl\n\nAdded in [API level 21](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract Uri getUrl ()\n```\n\nGets the URL for which the resource request was made.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-----------------------------------|---------------------------------------------------------|\n| [Uri](/reference/android/net/Uri) | the URL for which the resource request was made. \u003cbr /\u003e |\n\n### hasGesture\n\nAdded in [API level 21](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean hasGesture ()\n```\n\nGets whether a gesture (such as a click) was associated with the request.\nFor security reasons in certain situations this method may return `false` even though\nthe sequence of events which caused the request to be created was initiated by a user\ngesture.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-----------|-----------------------------------------------------------|\n| `boolean` | whether a gesture was associated with the request. \u003cbr /\u003e |\n\n### isForMainFrame\n\nAdded in [API level 21](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean isForMainFrame ()\n```\n\nGets whether the request was made in order to fetch the main frame's document.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-----------|----------------------------------------------------------------------------------------------------------------------------|\n| `boolean` | whether the request was made for the main frame document. Will be `false` for subresources or iframes, for example. \u003cbr /\u003e |\n\n### isRedirect\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean isRedirect ()\n```\n\nGets whether the request was a result of a server-side redirect.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-----------|--------------------------------------------------------------------|\n| `boolean` | whether the request was a result of a server-side redirect. \u003cbr /\u003e |"]]