How I can post a string to a PHP web server and get JSONArray in response using Volley library in Android. Following is my code in which I want response. How I can post a string and get JSONArray in response using this function
See this code if it works
JsonArrayRequest(Method.POST,Config.VIEW_PROFILE_URL,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
//calling method to parse json array
parseData(response);
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError arg0) {
// TODO Auto-generated method stub
}
}){
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
params.put("user_name", user);
return params;
}
};
MySingleton.getInstance(this).addToRequestQueue(jsonArrayRequest);
}
//and receiving at server like
$username =$_POST["user_name"];