java cookie注入_java-将cookie注入WebView不起作用

我在将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());

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值