Tencent / VasSonic

VasSonic is a lightweight and high-performance Hybrid framework developed by tencent VAS team, which is intended to speed up the first screen of websites working on Android and iOS platform.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

手动设置cookies失效

MrsLi opened this issue · comments

commented

What steps will reproduce the problem?
该问题的重现步骤是什么?

  1. 首次点击webview ,手动设置的cookies无效
  2. 退出再次点击,有效

What is the expected output? What do you see instead?
每次应该都能成功设置cookies的

What version of the product are you using? On what operating system?
你正在使用产品的哪个版本?在什么操作系统上?
最新版sdk(3.1.0) android 6.0系统

Please provide any additional information below.

设置cookies的代码如下:
/**
* 给webview添加cookie
* 此方法必须在setInitWebView()方法之前调用
*/
private void setWebViewCookie(String url) {
if (TextUtils.isEmpty(url)) return;
try {
CookieManager cookieManager = CookieManager.getInstance();
SharePreferenceHelper helper = new SharePreferenceHelper(this,Constant.USER_SP_NAME);
String cookie = (String) helper.getSharedPreference("cookie", "");
cookieManager.setCookie(url, cookie);

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(this);
            cookieSyncManager.sync();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}