我需要自定义标题添加到每个请求的web视图到来。我知道使用loadURL
有参数 extraHeaders
,但这些只适用于初始请求。所有后续请求不包含标头。我在 WebViewClient
看着都覆盖,但没有允许添加标题,以资源请求 - onLoadResource(web视图查看,字符串URL)
。任何帮助将是美好的。
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.
谢谢, 雷
尝试
loadUrl(String url, Map<String, String> extraHeaders)
不幸的是这仅适用于API8 +。
Unfortunately this only works on API8+.