4

我有一个代码将 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();
}

我调用flushAPI 如下所示。

/**
 * 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吗?

4

0 回答 0