1 /** 2 * 添加cookie 3 * 4 * @param url 5 */ 6 private void setCookie(String url) { 7 // 获取uid 8 String uid = UserDataCenter.getInstance().getUserId(WebBrowserActivity.this); 9 if (!TextUtils.isEmpty(uid)) { 10 // 写入cookie 11 CookieSyncManager.createInstance(WebBrowserActivity.this); 12 CookieManager cookieManager = CookieManager.getInstance(); 13 cookieManager.removeSessionCookie(); 14 cookieManager.removeAllCookie(); 15 String newCookie = "jzsz-uid=" + uid; 16 cookieManager.setCookie(goUrl, newCookie); 17 CookieSyncManager.getInstance().sync(); 18 } 19 }
1 if (StringKit.isNotEmpty(goUrl)) { 2 // 投票链接写入cookie 3 if (Const.URL_VOTE.equals(goUrl)) { 4 setCookie(goUrl); 5 } 6 mWebView.loadUrl(goUrl); 7 }
时间: 2024-10-14 10:08:15