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