开发者

Android HttpClient Cookie

开发者 https://www.devze.com 2023-01-25 09:53 出处:网络
Does Android HttpClient has auto-man开发者_C百科agement for cookies?It does support it. Reading the posts below it seems like you have to pass the same HttpContext when calling execute.

Does Android HttpClient has auto-man开发者_C百科agement for cookies?


It does support it.

Reading the posts below it seems like you have to pass the same HttpContext when calling execute.

response = httpClient.execute(httpPost,localContext); 

exactly how to do is in this post: Android project using httpclient --> http.client (apache), post/get method

How do I manage cookies with HttpClient in Android and/or Java?


You can make it static and use it in all requests

client =  new OkHttpClient();  // client will be static and use in all requests 

CookieManager cookieManager = new CookieManager();
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
client.setCookieHandler(cookieManager);
0

精彩评论

暂无评论...
验证码 换一张
取 消