How can I disable the Android WebView/WebViewClient from sending out a request for favicon.ico when I call WebView.loadUrl()? I can see the call being made while profiling r
You can simply pass some dummy InputStream to WebResourceResponse as shown below.
my_webview.webViewClient = object : WebViewClient() {
override fun shouldInterceptRequest(view: WebView?, request: WebResourceRequest?): WebResourceResponse? {
if (request?.url?.toString()?.toLowerCase()?.endsWith("/favicon.ico") == true) {
val inputStream = "".byteInputStream(Charset.defaultCharset())
return WebResourceResponse("text", "UTF-8", inputStream)
} else {
return super.shouldInterceptRequest(view, request)
}
}
}