Hello,
I'm sending POST to a PHP file using the Volley library. It all happens well until the application tries to show the response to the user. In the PHP file I use the echo 'user_created'; command. The application has the following error:
Error: com.android.volley.ParseError: org.json.JSONException: Value created_user of type java.lang.String can not be converted to JSONObject
I'm sorry for not being logcat, but I'm testing the application on a real cell.
Here is the code I use to send POST .
queue = Volley.newRequestQueue(this);
map.put("nickname", userName);
request = new JsonObjectRequest(
Request.Method.POST,
url,
new JSONObject(map),
new Response.Listener<JSONObject>(){
@Override
public void onResponse(JSONObject response){
Toast.makeText(ctx, "Resposta: " + response, Toast.LENGTH_LONG).show();
}
},
new Response.ErrorListener(){
@Override
public void onErrorResponse(VolleyError error){
Toast.makeText(ctx, "Erro: " + error, Toast.LENGTH_LONG).show();
}
}
);
queue.add(request);