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
for me the complete solution was:
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
if(url.toLowerCase().contains("/favicon.ico")) {
try {
return new WebResourceResponse("image/png", null, null);
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
@Override
@SuppressLint("NewApi")
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
if(!request.isForMainFrame() && request.getUrl().getPath().endsWith("/favicon.ico")) {
try {
return new WebResourceResponse("image/png", null, null);
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}