我有一个代码将 cookie 从 okHttp 写入 CookieManager,如下所示。
@Override
public void saveFromResponse(HttpUrl url, List<Cookie> cookies) {
CookieManager webviewCookieManager = CookieManager.getInstance();
String urlString = url.toString();
for (Cookie cookie : cookies) {
webviewCookieManager.setCookie(urlString, cookie.toString());
}
webviewCookieManager.flush();
}
我调用flush
API 如下所示。
/**
* Ensures all cookies currently accessible through the getCookie API are
* written to persistent storage.
* This call will block the caller until it is done and may perform I/O.
*/
public abstract void flush();
但是,即使我删除它,它setCookie
本身似乎也已经存在。我还需要flush
吗?