【发布时间】:2014-09-18 15:34:23
【问题描述】:
Volley 给了我们更好的效率,但是它使用了“url”
JsonObjectRequest j = new JsonObjectRequest((int method, String url, JSONObject jsonRequest, Listener<JSONObject> listener, ErrorListener errorListener);
但是如果我必须使用 HttpPost 或 HttpGet 对象,因为我必须设置 Header 和 Entity 等。我该如何在仍然使用 Volley 的同时做到这一点。
HttpGet httpGet = new HttpGet(url);
httpGet.setHeader("String", "something" );
httpGet.setHeader("Content-Type","application/json");
...
httpPost.setEntity(new StringEntity("whatever"));
基本上在这几行代码之后,我得到了 HttpPost / HttpGet 对象;有没有办法在 volley 中使用这个对象而不是使用 HttpClient 来执行请求。
或者是否有一些不同的方法来设置标题等,然后将其与 Volley 一起使用。
【问题讨论】:
标签: java android apache android-volley