0
I am with the following problem, I am making an app q contains login and user registration and I am using PHP and JSON code for this. However I checked my Response.Listener is never called, the execution jumps it... The code that’s on Main:
Response.Listener<String> responseListener = new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
Toast.makeText(Register.this, "entrou", Toast.LENGTH_SHORT).show();
JSONObject jsonObject = new JSONObject(response);
boolean success = jsonObject.getBoolean("success");
if(success)
{
Toast.makeText(Register.this, "Entrou", Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(Register.this, "Erro", Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};
And this is my Registerrequest:
public class RegisterRequest extends StringRequest {
private static final String REGISTER_REQUEST_URL = "kameo.com.br/control/ayzac_control_signin_mobile.php";
private Map<String, String> params;
public RegisterRequest(String email, String name, String nickname, String password, String date, String gender, Response.Listener<String> listener)
{
super(Method.POST, REGISTER_REQUEST_URL, listener, null);
params = new HashMap<>();
params.put("userEmail", email);
params.put("userName", name);
params.put("userNickname", nickname);
params.put("userPassword", password);
params.put("userBirth", date);
params.put("userGender", gender);
}
@Override
public Map<String, String> getParams() {
return params;
}
}
I think you are using Volley. If so you need to add the request to Requestqueue.
– ramaral
RegisterRequest registerRequest = new RegisterRequest(email, username, usernick, password, birthdate, gender, responseListener);
 RequestQueue queue = Volley.newRequestQueue(Register.this);
 queue.add(registerRequest);

I put the Request Queue– Crash_Override
Implement the
Response.ErrorListener
to see if there are any mistakes.– ramaral