Android WebView获取cookie

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/yechaoa/article/details/77839605


重写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());


展开阅读全文

没有更多推荐了,返回首页