我有一个我的应用程序的注册表单,并且凌空将请求发送到服务器上的php文件,我看到用户在数据库上注册,但响应侦听器没有收到响应,允许它返回到主页 这是我的android代码
if (rdPassword.equals(rdPassword2)) {
if(rdEmail.matches(emailPattern)||rdEmail.matches(emailPattern2)){
Response.Listener<String> responseListener = new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
System.out.println(response);
JSONObject jsonResponse = new JSONObject(response);
boolean success = jsonResponse.getBoolean("success");
if (success) {
pd.dismiss();
Intent bktohome = new Intent(driver_registration.this, home.class);
bktohome.putExtra("company", rdCompany);
startActivity(bktohome);
finish();
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(driver_registration.this);
builder.setMessage("Register Failed")
.setNegativeButton("Retry", null)
.create()
.show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};
DriverRegistration registerRequest = new DriverRegistration(rdUsername, rdPassword, rdName, rdEmail,
rdMobile, rdCompany, rdAddress, rdSSN, rdDLN,rdImage_encoded, responseListener);
RequestQueue queue = Volley.newRequestQueue(driver_registration.this);
queue.add(registerRequest);
}
else
{
AlertDialog.Builder builder = new AlertDialog.Builder(driver_registration.this);
builder.setMessage("Wrong Email Format...")
.setNegativeButton("Retry",null)
.create()
.show();
}
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(driver_registration.this);
builder.setMessage(" Passwords do not match")
.setNegativeButton("Retry", null)
.create()
.show();
}
DriverRegistration类
public class DriverRegistration extends StringRequest {
private static final String REGISTER_REQUEST_URL = "http://trackitfinal.hostei.com/registerDriver.php";
private Map<String , String> params;
public DriverRegistration(String username , String password , String name , String email , int mobile , String company , String address ,
int SSN , int DLN,String rdImage_encoded, Response.Listener<String> listener)
{
super(Method.POST,REGISTER_REQUEST_URL,listener,null);
params=new HashMap<>();
params.put("username",username);
params.put("password",password);
params.put("name",name);
params.put("email",email);
params.put("mobile",mobile+"");
params.put("company",company);
params.put("address",address);
params.put("SSN",SSN+"");
params.put("DLN",DLN+"");
params.put("image",rdImage_encoded);
}
@Override
public Map<String, String> getParams() {
return params;
}
}
答案 0 :(得分:0)
检查你的Api是否正常工作,并在用户点击它时发送正确的响应,或者它可能只是更新数据库。是否有获取用户详细信息的Api,您可以通过点击它或在邮递员中检查它来检查它。