문제

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