The example in this article describes the way that the Android implementation HTTP requests access to add cookies. Share to everyone for your reference, specific as follows:
First Kind
hashmap<string, string> map = new hashmap<string, string> ();
Map.put ("Cookie", "p1u_id=4eb591e73554db0f4d3300cb656113abfb968ef6b0ee2b5de0a35caa5217c51faa028b453576b35c");
Networkconnection.setheaderlist (map);
Networkconnection.connectionresult result = Networkconnection.execute ();
The second is the use of 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 ();
}
I hope this article will help you with the Android program.