I work in an android app and I got a problem that I can't solve, I tried searching on google and do it in another way but I'm stuck. Here's my code:
private FirebaseAuth mAuth;
private FirebaseFirestore db;
private Boolean complete=false;
public boolean createUser(final String prenom, final String nom, final String mail, final String pass) {
RegisterActivity ra = new RegisterActivity();
mAuth = FirebaseAuth.getInstance();
db = FirebaseFirestore.getInstance();
mAuth.createUserWithEmailAndPassword(mail, pass).addOnCompleteListener(ra, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
mAuth.getCurrentUser().sendEmailVerification();
Map<String, Object> user = new HashMap<>();
user.put("Mail", mail);
user.put("Nom", nom);
user.put("Prenom", prenom);
user.put("Rang", "Aucun");
user.put("Valide", false);
db.collection("users").document(mAuth.getCurrentUser().getUid()).set(user).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
complete=true;
Log.w("RESULT",complete.toString());
}
});
}
});
Log.w("RESULT",complete.toString());
return complete;
}
I don't know why my function return false, the log says in first "RESULT false" and after "RESULT true". What's wrong ?