Android WebView获取cookie


重写WebViewClient方法

public class MyWebViewClient extends WebViewClient {

    public boolean shouldOverrideUrlLoading(WebView webview, String url) {
        webview.loadUrl(url);
        return true;
    }

    public void onPageFinished(WebView view, String url) {
        CookieManager cookieManager = CookieManager.getInstance();
        String CookieStr = cookieManager.getCookie(url);
        LogUtil.i("Cookies", "Cookies = " + CookieStr);
        super.onPageFinished(view, url);
    }

}

调用

mWebView.setWebViewClient(new MyWebViewClient());


你可能感兴趣的:(Android,知识点)