Я получаю это, когда нажимаю кнопку регистрации в моем приложении.
10-20 20:32:13.688 9146-9146/asylum.lotto.steed.codelotto W/System.err: org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
at org.json.JSON.typeMismatch(JSON.java:111)
10-20 20:32:13.689 9146-9146/asylum.lotto.steed.codelotto W/System.err: at org.json.JSONObject.<init>(JSONObject.java:160)
at org.json.JSONObject.<init>(JSONObject.java:173)
at asylum.lotto.steed.codelotto.login.SignUpActivity$1$1.onResponse(SignUpActivity.java:51)
10-20 20:32:13.690 9146-9146/asylum.lotto.steed.codelotto W/System.err: at asylum.lotto.steed.codelotto.login.SignUpActivity$1$1.onResponse(SignUpActivity.java:47)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:60)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
at android.os.Handler.handleCallback(Handler.java:836)
10-20 20:32:13.691 9146-9146/asylum.lotto.steed.codelotto W/System.err: at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
Я думаю, что проблема где-то в моем классе регистрации Java.Я довольно плохо знаком со всей базой данных, но думаю, что есть проблема с преобразованием в JSON.
register.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
final String name = regname.getText().toString();
final String username = regusername.getText().toString();
final String password = regpassword.getText().toString();
Response.Listener<String> responseListeer = new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonResponse = new JSONObject(response);
boolean success = jsonResponse.getBoolean("success");
if(success){
Intent intent = new Intent(SignUpActivity.this, SigninActivity.class);
SignUpActivity.this.startActivity(intent);
}else{
AlertDialog.Builder builder = new AlertDialog.Builder(SignUpActivity.this);
builder.setMessage("Register Failed").setNegativeButton("Retry", null).create().show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};
RegisterRequest registerRequest = new RegisterRequest(name, username, password, responseListeer);
RequestQueue queue = Volley.newRequestQueue(SignUpActivity.this);
queue.add(registerRequest);
}
});
}
}