Android : HttpPost and HttpGet object to url so as to be able to use with Volley?

on Wednesday, September 17, 2014


Volley gives us better efficiency, however it uses the "url"



JsonObjectRequest j = new JsonObjectRequest((int method, String url, JSONObject jsonRequest, Listener<JSONObject> listener, ErrorListener errorListener);


But if I have to use HttpPost or HttpGet object as I have to set Header and Entity etc. How can I do it while still using Volley.



HttpGet httpGet = new HttpGet(url);
httpGet.setHeader("String", "something" );
httpGet.setHeader("Content-Type","application/json");
...
httpPost.setEntity(new StringEntity("whatever"));


basically after these lines of code I get HttpPost / HttpGet object; is there a way to use this object in volley instead of using HttpClient to execute the request.


Or is there a some different way to set header etc and then use it with Volley.


0 comments:

Post a Comment