大家好我在我的代码中有一个错误希望你可以帮助我从中了解更多信息,我的php页面和数据库已准备好并连接,但是当我试图在我的应用程序中注册时,我看到这个erorr
活性:
EditText name, email, password, password2;
Button bt1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registration);
name = (EditText) findViewById(R.id.ed1);
email = (EditText) findViewById(R.id.ed2);
password = (EditText) findViewById(R.id.ed3);
password2 = (EditText) findViewById(R.id.ed4);
bt1 = (Button) findViewById(R.id.bt1);
bt1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String Ename = name.getText().toString().trim();
String Email = email.getText().toString().trim();
String Pass = password.getText().toString().trim();
String Pass2 = password2.getText().toString().trim();
if (!Pass.equals(Pass2)) {
Toast.makeText(Registration.this, "Password doesnt match!", Toast.LENGTH_SHORT).show();
} else {
Response.Listener<String> responseLisener = new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonRespone = new JSONObject(response);
boolean success = jsonRespone.getBoolean("success");
if (success) {
Toast.makeText(Registration.this, "Registartion Complete!", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(Registration.this, "Something wen wrong, Registration uncompleted", Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};
Send_Data_Registration send_Data = new Send_Data_Registration(Ename, Email, Pass, responseLisener);
RequestQueue queue = Volley.newRequestQueue(Registration.this);
queue.add(send_Data);
}
}
});
}
}
这是类Send_Data_Registartion
public class Send_Data_Registration extends StringRequest {
private static final String SEND_DATA_URL = "http://dev-redakhalaf.000webhostapp.com/Registration.php";
private Map<String,String>MapData;
public Send_Data_Registration(String name , String email, String password, Response.Listener<String> listener){
super(Method.POST,SEND_DATA_URL, listener,null);
MapData = new HashMap<>();
MapData.put("ename",name);
MapData.put("email",email);
MapData.put("epassword",password);
}
@Override
protected Map<String, String> getParams() {
return MapData;
}
}
这是erorr:
W/System.err: org.json.JSONException: Value <? of type java.lang.String cannot be converted to JSONObject
W/System.err: at org.json.JSON.typeMismatch(JSON.java:111)
W/System.err: at org.json.JSONObject.<init>(JSONObject.java:163)
W/System.err: at org.json.JSONObject.<init>(JSONObject.java:176)
W/System.err: at com.example.redakhalaf.lessons.Registration$1$1.onResponse(Registration.java:49)
W/System.err: at com.example.redakhalaf.lessons.Registration$1$1.onResponse(Registration.java:45)
W/System.err: at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:60)
W/System.err: at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
W/System.err: at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
W/System.err: at android.os.Handler.handleCallback(Handler.java:789)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:98)
W/System.err: at android.os.Looper.loop(Looper.java:164)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6541)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)