[英]Firebase authentication - users being created in console but progress bar won't stop spinning and the task is not completed?
So I am working on the registration form for a mobile-app and when a user fills out the registration form and submits, the progress bar appears and spins indefinitely and surprisingly no message is printed.所以我正在处理移动应用程序的注册表,当用户填写注册表并提交时,进度条会出现并无限旋转,令人惊讶的是没有打印任何消息。 In spite of this the users do appear in the firebase console causing me unthinkable bamboozlement.
尽管如此,用户确实出现在 Firebase 控制台中,这让我感到不可思议。
Code:代码:
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);
}
}
});
}
}
});
Thanks!谢谢!
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);
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
progressBar.setVisibility(View.GONE)
}
});
Add this failure listener.添加此失败侦听器。 So you can get failed message or do what you want.
所以你可以得到失败的消息或做你想做的事。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.