因此,我正在为一个移动应用程序编写注册表,当用户填写注册表并提交时,进度条会出现并无限旋转,令人惊讶的是,没有打印任何消息。尽管如此,用户还是出现在firebase控制台上,这让我难以置信。
代码:
progressBar.setVisibility(View.VISIBLE);
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if(task.isSuccessful()) {
User user = new User(fullName, rating, email);
System.out.println(user.fullName);
FirebaseDatabase.getInstance().getReference("Users")
.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
.setValue(user).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful()) {
Toast.makeText(RegisterUser.this, "User has been registered succesfully!", Toast.LENGTH_LONG).show();
System.out.println("Success!");
progressBar.setVisibility(View.GONE);
}else {
Toast.makeText(RegisterUser.this, "Failed to register!
Try again!", Toast.LENGTH_LONG).show();
System.out.println("Failure!");
progressBar.setVisibility(View.GONE);
}
}
});
}
}
});
谢谢
1条答案
按热度按时间piah890a1#
添加此失败侦听器。所以你可以得到失败的消息或做你想做的事。