i must do i request with Volley Framework. This is a POST request with JSONObject.
I must pass one string and one JSONArray..but how i can?
I start with this
JSONObject can take in Java Objects, try using
Map
something like this:
String mUrl; //initialized somewhere else
ArrayList mUrlDove; //initialized somewhere else
Map jsonParams = new HashMap<>();
jsonParams.put("url", mUrl);
jsonParams.put("urlDove", mUrlDove);
JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, url, new JSONObject(jsonParams),
new Response.Listener()
{
@Override
public void onResponse(JSONObject response)
{
Log.d("Volley Response: ", response.toString());
//do the other stuff you need...
}
},
new Response.ErrorListener()
{
@Override
public void onErrorResponse(VolleyError error)
{
if (null != error.networkResponse)
{
Log.d(" Volley Error Code: ", "" + error.networkResponse.statusCode);
//probably throw an Exception or some MessageEvent
}
}
});
requestQueue.add(request);
this works for me with complex objects like
Map>>
with the most inner objects being Strings and Integers, and the List being initialized as a new ArrayList.
Hope this Helps!