发布网友 发布时间:2022-05-18 15:12
共1个回答
热心网友 时间:2023-10-18 18:22
可以在 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);}}