[英]Firebase authentication - users being created in console but progress bar won't stop spinning and the task is not completed?
所以我正在處理移動應用程序的注冊表,當用戶填寫注冊表並提交時,進度條會出現並無限旋轉,令人驚訝的是沒有打印任何消息。 盡管如此,用戶確實出現在 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);
}
}
});
}
}
});
謝謝!
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)
}
});
添加此失敗偵聽器。 所以你可以得到失敗的消息或做你想做的事。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.