So the flow will go like this:
- user login with email and password via firebase
- if email is verified, they will go to the main activity else they will go to the verify email activity
What I wanted to do is when they are at the verify email activity, I will send a verification email in onCreate method, then if the email is verified (in run time), I will send the user to the main activity.
I know the function to check if user verify email is by
firebaseAuth.getCurrentUser().isEmailVerified()
The problem here is how can I use this function (or others) to check if the user verify their email in real time.
I've tried doing this using a while loop, but it does not work out as expected :
firebaseAuth.getCurrentUser().sendEmailVerification().addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
//verify email sent
Alert("Verification email send");
//PROBLEM STARTS HERE
boolean v = true;
while(v){
if(firebaseAuth.getCurrentUser().isEmailVerified()){
v = false;
break;
}
}
if(!v){
Alert("Email verified");
startActivity(new Intent(getApplicationContext(), MainActivity.class));
finish();
}
}
});