如何修复Android Studio中发生的太多事情

时间:2016-06-18 01:08:00

标签: java php android database android-studio

问题肯定来自这段代码。

 bRegister.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            final String username = etuserame.getText().toString();
            final String email = etemail.getText().toString();
            final String password = etpassword.getText().toString();

            Response.Listener<String> responseListener = 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(RegisterActivity.this, LoginActivity.class);
                            RegisterActivity.this.startActivity(intent);
                        } else {
                            AlertDialog.Builder builder = new AlertDialog.Builder(RegisterActivity.this);
                            builder.setMessage("Register Failed")
                                    .setNegativeButton("Retry", null)
                                    .create()
                                    .show();
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            };

            RegisterRequest registerRequest = new RegisterRequest(username, email, password, responseListener);
            RequestQueue queue = Volley.newRequestQueue(RegisterActivity.this);
            queue.add(registerRequest);

当用户点击register时,它不会打开新活动,我的数据库中什么都没有。我只是因为没有窗口焦点和太多进程运行而得到取消事件。 这是我的RegisterRequest课程。

private Map<String, String> params;

public RegisterRequest(String username, String email, String password, Response.Listener<String> listener){
    /*
    NExt line means we are going to pass some information into the register.php
     */
    super(Method.POST, REGISTER_REQUEST_URL, listener, null);
    /*
    This is how we pass in the information from the register to the thing, we are using a hashmap
     */
    params = new HashMap<>();
    params.put("username", username);
    params.put("email", email);
    params.put("password", password);

}
/*
Volley needs to get the data so we do a get params
Which gives us this method
 */

@Override
public Map<String, String> getParams() {
    return params;
}
}

0 个答案:

没有答案