如何在Android中制作Cookie容器?
我发现在vb.net中,在webclient中继承。是这样的:
**Private cookieCont As New Net.CookieContainer()**
Private lastPage As String
Protected Overrides Function GetWebRequest(ByVal address As System.Uri) As System.Net.WebRequest
Dim wr = MyBase.GetWebRequest(address)
If TypeOf wr Is Net.HttpWebRequest Then
With DirectCast(wr, Net.HttpWebRequest)
**.CookieContainer = cookieCont**
If lastPage IsNot Nothing Then
.Referer = lastPage
End If
End With
End If
lastPage = address.ToString()
Return wr
End Function
谢谢!
答案 0 :(得分:0)
这可以使用CookieManager实现。看看下面的链接
答案 1 :(得分:0)
您可以使用CookieManager,它会在您使用HTTP时自动管理cookie,您也可以使用自定义CookieStore和自定义CookiePolicy自定义它
http://docs.oracle.com/javase/tutorial/networking/cookies/index.html
此链接可以学习如何自定义CookieManager