Вопрос

Is there a way to set the WebView to have:

Do not track

option like Chrome app?

Это было полезно?

Решение

"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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top