Pregunta

Is there a way to set the WebView to have:

Do not track

option like Chrome app?

¿Fue útil?

Solución

"Do not track" is actually an HTTP header (DNT). So you should be able to do this by adding that header to every request by way of loadUrl(url, headers). For example:

webView.setWebViewClient(new WebViewClient()
{
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url)
    {
        HashMap<String, String> extraHeaders = new HashMap<String, String>();
        extraHeaders.put("DNT", "1");
        view.loadUrl(url, extraHeaders); 
        return true;
    } 
});

Note that this loadUrl() overload requires API level 8.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top