Ich habe eine json wie diese senden:Wie kann ich String-Array durch Volley senden?
{
"user_id": "5750891ffe77d2d41732d535",
"categories" :["5751cd8cb61c39200b368cf3","575b35b9c456c8751cd8530f", "575b35c5c456c8751cd85313"]
}
aber volley nur Strings senden, kein Array. Das ist mein Wunsch Klasse, ich bin mit dem Volley StringRequest aber ich denke, es gibt eine Möglichkeit, auch eine Reihe an:
public class VolleyRequest extends StringRequest {
private Map<String, String> params;
Context context;
public VolleyRequest(int method, final Context context, String url, Map<String, String> params, final Response.Listener<String> listener) {
super(method, url, listener, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
Log.d("WS", volleyError.toString());
}
});
setRetryPolicy(new DefaultRetryPolicy(10000, 10, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
this.params = params;
this.context = context;
}
@Override
public String getBodyContentType() {
return "application/x-www-form-urlencoded; charset=UTF-8";
}
@Override
public Map<String, String> getParams() throws AuthFailureError {
return this.params;
}
}
Mögliche Duplikat [Volley Post-Methode für JSON-Objekt] (http://stackoverflow.com/questions/25906689/volley-post-method-for-json-object) –