I have an activity where I want the user to wait until email account is verified, but it is not taking the user to mainActivity once account is verified, how should I address this?
See my code below;
user.sendEmailVerification();
final Handler handler = new Handler();
final int delay = 10000; //milliseconds
handler.postDelayed(new Runnable() {
public void run() {
if (user.isEmailVerified()) {
startActivity(new Intent(VerificationEmailActivity.this, MainActivity.class));
Toast.makeText(VerificationEmailActivity.this, R.string.spend_wisely, Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(VerificationEmailActivity.this, "Check your email!", Toast.LENGTH_SHORT).show();
}
handler.postDelayed(this, delay);
}
}, delay);
}
CodePudding user response:
Since the actual verification of the user happens outside of your Android app (in your browser), the app is not aware that it happens. This means that the app only detects the user's updated state once it auto-refreshes the token, which can take up to an hour.
To detect it earlier, you can reload the profile by calling reload()
, or forcing the refresh of the ID token by calling getIdToken(true)
.
This has been covered quite a few times already, so also check out: