I need to add custom headers to EVERY request coming from the WebView. I know loadURL
has the parameter for extraHeaders
, but those are only applied to the initial request. All subsequent requests do not contain the headers. I have looked at all overrides in WebViewClient
, but nothing allows for adding headers to resource requests - onLoadResource(WebView view, String url)
. Any help would be wonderful.
Thanks, Ray
Try
loadUrl(String url, Map<String, String> extraHeaders)
For adding headers to resources loading requests, make custom WebViewClient and override:
API 24+:
WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request)
or
WebResourceResponse shouldInterceptRequest(WebView view, String url)