0
Ich benutze volley-bibliothek für die anfrage. Ich muss Param als JSON-Array veröffentlichen, weil ich es auf der anderen Seite als JSON-Array empfange. Wie kann ich meine Parameter in JSON Array konvertieren? hier ist mein Codeposten params als json in android volley
public void SendData() {{
final StringRequest strReq = new StringRequest(Request.Method.POST, GET_STUDENTS_BY_ID, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.v("failedd",response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e("Error", "Registration Error: " + error.getMessage());
}
})
{
@Override
protected Map<String, String> getParams() {
// Posting params to register url
Map<String, String> params = new HashMap<String, String>();
params.put("user_id", user_id);
params.put("student_id", studId);
params.put("to", tomail);
params.put("subject", subjects);
params.put("description", descriptions);
return params;
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json; charset=utf-8");
return headers;
}
};
AppController.getInstance().addToRequestQueue(strReq, tag_json_obj);
}
bitte helfen ..
Welche Bibliothek Sie mcxiaoke Volley oder Googles neue Volley verwendet ?? – Nikhil
Googles neuer Volley – Bivin
Es gibt Syntaxfehler ... .Sorry für das jetzt versuchen Sie bitte 'neues JSONObject (params)' anstelle von 'neuem JsonObject (params)'. – Nikhil