I have registration page and in this page i have to send person image along with person details to my server using Volley library, the problem is I'm looking for a how to do it but still haven't found. can some one help me please
MainActivity:-
JSONObject request = new JSONObject();
try {
request.put("username", "ramu");
request.put("password", "12345");
request.put("firstname", "rk");
request.put("lastname", "ram");
//Along with this parameters i have to send person image also
} catch (JSONException e) {
e.printStackTrace();
}
String url = "MYURL";
VolleyBackgroundCode.getJsonRequest(MainActivity.this, url, request.toString());
VolleyBackgroundCode:-
public static void getJsonRequest(Context _Context, String url, final String body) {
RequestQueue queue = Volley.newRequestQueue(_Context.getApplicationContext());
StringRequest request = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
return;
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
return headers;
}
@Override
public byte[] getBody() {
return body.toString().getBytes();
}
@Override
public String getBodyContentType() {
return "application/json";
}
@Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {
return super.parseNetworkResponse(response);
}
};
request.setRetryPolicy(new DefaultRetryPolicy(2000, 3, 1.5f));
queue.add(request);
}
}