最佳答案
我想发送一个新的 JsonObjectRequest
请求:
我希望将带有此请求的 JSON 格式的数据发送到服务器
JsonObjectRequest request = new JsonObjectRequest(
Request.Method.POST, "myurl.com", null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
//...
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
//...
}
})
{
@Override
protected Map<String,String> getParams() {
// something to do here ??
return params;
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
// something to do here ??
return params;
}
};
P.S. I use GSON library in my project too.