我在将cookie注入login.php页面时遇到一些问题.这是代码:
LinearLayout lLayout = (LinearLayout)findViewById(R.id.linearlayoutIdLogin);
lLayout.setVisibility(View.GONE); //make my standard layout inivisible
LinearLayout lWeb = (LinearLayout)findViewById(R.id.webviewId);
lWeb.setVisibility(View.VISIBLE); //make my webview visible
WebView browse = (WebView)findViewById(R.id.webViewBrowse);
上面的代码是正确的.我加载了WebView,但是页面显示我需要登录.
这是cookie注射,对我不起作用.
Cookie setcookie = cookie.get(1);
Cookie othercookie = cookie.get(0);
/* I assign my two cookies from a List. cookie.get()
brings the element I need. The cookies overall contains two fields. Therefore
the get 1 and get 0. All this works, I have tested to make a Toast to
print out the cookies */
//Here it must be anything I'm doing wrong?
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
cookieManager.setCookie("http://www.thedomain.com", setcookie.getValue());
browse.setWebViewClient(new WebViewClient(){ });
browse.loadUrl("mypagewhenloggedin.php");
有任何想法吗?已经坚持了几个小时.提前致谢!
编辑代码:
忘了说我也添加了这个cookie.
cookieManager.setCookie(“ http://www.thedomain.com”,othercookie.getValue());