I want to open a Admin activity when the defined admin e mail signs in, without using role based auth. I've tried the below but it keeps opening the profileActivity when I sign in with the admin@admin.com e mail, could anyone assist? Edited to include the full code. I'm trying to firstly check if the user trying to log in is registered and if they are, do they have an admin e mail address, if so, take them to the admin area, if not, take them to the profile area. Thanks
progressBar.setVisibility(View.VISIBLE);
mAuth.signInWithEmailAndPassword(email, password). addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
String loggedInUserEmail = mAuth.getCurrentUser().getEmail();
String adminEmailAddress = "admin@admin.com";
progressBar.setVisibility(View.GONE);
if(task.isSuccessful() && (loggedInUserEmail.equals(adminEmailAddress))) {
finish(); // finish activity
Intent intent = new Intent(MainActivity.this, adminActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
if(task.isSuccessful()) {
finish(); // finish activity
Intent intent = new Intent(MainActivity.this, ProfileActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
else
{
Toast.makeText(getApplicationContext(), task.getException().getMessage(),Toast.LENGTH_SHORT).show();
}
}
});