欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

android實(shí)現(xiàn)http中請(qǐng)求訪問添加cookie的方法

 更新時(shí)間:2015年10月28日 12:33:03   作者:wanqi  
這篇文章主要介紹了android實(shí)現(xiàn)http中請(qǐng)求訪問添加cookie的方法,實(shí)例分析了兩種添加cookie的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了android實(shí)現(xiàn)http中請(qǐng)求訪問添加cookie的方法。分享給大家供大家參考,具體如下:

第一種

HashMap<String, String> map = new HashMap<String, String>();
map.put("cookie","p1u_id=4eb591e73554db0f4d3300cb656113abfb968ef6b0ee2b5de0a35caa5217c51faa028b453576b35c");
networkConnection.setHeaderList(map);
NetworkConnection.ConnectionResult result = networkConnection.execute();

第二種是用okhttp

OkHttpClient client = new OkHttpClient();
String returnData=null;
com.squareup.okhttp.Request request = new com.squareup.okhttp.Request.Builder()
  .addHeader("cookie", "p1u_id=4eb591e73554db0f4d3300cb656113abfb968ef6b0ee2b5de0a35caa5217c51faa028b453576b35c")
  .url(url)
  .build();
Response response = null;
try {
  response = client.newCall(request).execute();
  returnData=response.body().string();
  Log.i("ss", "url is " + url + "_______RETUNRN DATA IS " + returnData);
} catch (IOException e) {
  e.printStackTrace();
}

希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論