我是否需要在CookieManager中的setCookie之后刷新?

时间:2017-11-08 01:53:19

标签: android webkit android-webview cookiemanager android-cookiemanager

我有一个代码将okHttp中的cookie写入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吗?

0 个答案:

没有答案