webview添加cookie有时失效

本文介绍了一种从DefaultHttpClient向Android WebView组件传递Cookies的方法。作者在Android 2.2上尝试了多种教程,但Cookies并未正确发送到WebView。通过实验发现,在removeSessionCookie和setCookie方法间稍作延迟能够解决问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转载:http://code.walletapp.net/post/46414301269/passing-cookie-to-webview

Passing cookie to webview

In few following lines I will describe my solution, how to pass cookies from DefaultHttpClient to WebView component. I was following many tutorials, but cookies weren’t send to WebView properly (in my Android 2.2). After several experiments I found out that it is working, when we wait a little time between removeSessionCookie and setCookie methods. I don’t know why. But important is, that it is working right now for me.

Look at the following source code:

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值