更新时间:2023-12-01 09:31:04
您要在调用auth.createUserWithEmailAndPassword之前检查条件.
You want to check your conditions before calling auth.createUserWithEmailAndPassword.
您的if语句上还缺少{,因此它没有达到您的期望.应该看起来像这样:
You've also got a missing { on your if statement, so its not doing what you expect. Should look something like this:
private void signUpUser(String email, final String password) {
if (password.length() < 6) {
snackbar = Snackbar.make(activity_criar_conta, "Your password must have at least 6 characters.", Snackbar.LENGTH_SHORT);
snackbar.show();
return;
}
String pass2 = etConfirmarSenha.getText().toString();
if (!password.equals(pass2)) {
snackbar = Snackbar.make(activity_criar_conta, "Both password fields must be identical", Snackbar.LENGTH_SHORT);
snackbar.show();
return;
}
auth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
String emailuser = etCriarEmail.getText().toString();
snackbar = Snackbar.make(activity_criar_conta, "Your account was created with sucess: "+emailuser,Snackbar.LENGTH_SHORT);
snackbar.show();