这个问题不是随时重现,我们在同步之前会先删除所有之前的cookies,调用:
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP /*&& method != null*/){cookieManager.removeSessionCookies(new ValueCallback() {@Overridepublic void onReceiveValue(Boolean value) {Log.d(TAG, "onReceiveValue value:"+value);}});}else{ cookieManager.removeSessionCookie();}
经过查阅n多stackoverflow后发现一个答案:You have used this line - if (sessionCookie != null) { cookieManager.removeSessionCookie(); }. To ensure you receive new cookie everytime.Seems like you have gone through same issue as I faced, check below link -removeSessionCookie() issue of android (code.google.com)it says that removeSessionCookie() is implemented in a thread, so whenever it is called; a thread starts and after your setCookie(url, cookieString); is called, it removes the new cookie you just set. So for some devices it works well as removeSessionCookie() i