注册用户-添加的字段

因此,我正在尝试为我的Android应用程序注册用户,当前它使用Firebase身份验证通过电子邮件和密码进行注册。但我也想添加一个名称和电话字段进行注册。

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

            // register name/phone/radiogroup


            final String name = nameField.getText().toString();
            final String phone = phoneField.getText().toString();
            final String email = Email.getText().toString();
            final String password = Password.getText().toString();

            if (TextUtils.isEmpty(name)) {
                Toast.makeText(TradesmanLoginActivity.this,
                        "Please enter your Name...", Toast.LENGTH_SHORT).show();
            }

            if (TextUtils.isEmpty(phone)) {
                Toast.makeText(TradesmanLoginActivity.this,
                        "Please enter your Phone Number...", Toast.LENGTH_SHORT).show();
            }

            if (TextUtils.isEmpty(email)) {
                Toast.makeText(TradesmanLoginActivity.this,
                        "Please enter your Email Address...", Toast.LENGTH_SHORT).show();
            }

            if (TextUtils.isEmpty(password)) {
                Toast.makeText(TradesmanLoginActivity.this,
                        "Please enter a Password...", Toast.LENGTH_SHORT).show();
            } else {
                loadingBar.setTitle("Tradesman Registration");
                loadingBar.setMessage("Please wait while we check your credentials...");
                loadingBar.show();

                Auth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(TradesmanLoginActivity.this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        if (!task.isSuccessful()) {
                            Toast.makeText(TradesmanLoginActivity.this, "sign up error", Toast.LENGTH_SHORT).show();
                            loadingBar.dismiss();
                        } else {
                            Toast.makeText(TradesmanLoginActivity.this, "Tradesman Registration Successful!", Toast.LENGTH_SHORT).show();
                            loadingBar.dismiss();

                            String name = nameField.getText().toString();
                            String phone= phoneField.getText().toString();

                            HashMap<String,String> user=new HashMap<>();
                            user.put("Name",name);
                            user.put("Phone",phone);


                            String user_id = Auth.getCurrentUser().getUid();
                            DatabaseReference current_user_db = FirebaseDatabase.getInstance().getReference().child("Users").child("Tradesman").child(user_id).child("Name");
                            current_user_db.setValue(email);
                        }
                    }
                });
            }
        }
    });

我已经创建了字段等,我只是在努力将名称和电话放入Firebase数据库中。

当前,它注册用户并将“名称”设置为用户电子邮件。我想将姓名和电话存储为用户ID(在注册时输入)的子代,而不只是电子邮件

评论