发布网友 发布时间:2022-05-13 12:32
共1个回答
热心网友 时间:2022-04-21 18:14
我们可以在 WebViewClient 的 onPageFinished(WebView view, String url) 方法中使用 CookieManager 来获取加载完成之后网页中携带的 Cookie 值,代码如下:private class MyWebViewClient extends WebViewClient { public boolean shouldOverrideUrlLoading(WebView view, String url) { webview.loadUrl(url); return true; } public void onPageFinished(WebView view, String url) { CookieManager cookieManager = CookieManager.getInstance(); String CookieStr = cookieManager.getCookie(url); Log.e("sunzn", "Cookies = " + CookieStr); super.onPageFinished(view, url); } }