I am the beginner in java programing I am trying to create 2 way login system in app the 1st one is Email and the 2nd one is with phone number but I am stuck in identifying the user that the user is logged in with phone number or with email On my splash screen first I checked that user is null or no if it is not null then Second I checked that the user Email is Verified or not if the user email is verified then the user can go to the main app but if the user email is not verified then he should go to the verification page where he should first verify his account but if the user is logged in with his phone number he should just go to the main app But my problem is that when is signup with phone number and i open the app it goes to the verification email page.
public class SplashScreen extends AppCompatActivity
{
ImageView icon;
TextView app;
RelativeLayout relativeLayout;
Animation layout;
private FirebaseAuth mAuth;
FirebaseUser firebaseUser;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
mAuth = FirebaseAuth.getInstance();
app = findViewById(R.id.splash_scren_app);
relativeLayout = findViewById(R.id.splash_srceen);
icon = findViewById(R.id.splash_srceen_icon);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
relativeLayout.setVisibility(View.VISIBLE);
relativeLayout.setAnimation(layout);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
app.setVisibility(View.VISIBLE);
icon.setVisibility(View.VISIBLE);
}
},500);
}
},1000);
if (firebaseUser!=null)
{
new Handler().postDelayed(new Runnable() {
@Override
public void run()
{
if (firebaseUser.isEmailVerified())
{
Intent intent = new Intent(SplashScreen.this,MainActivity.class);
startActivity(intent);
finish();
}
else
{
Intent intent = new Intent(SplashScreen.this,EmailVerification.class);
startActivity(intent);
finish();
}
}
},5000);
}
else
{
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(SplashScreen.this,WelcomeScreen.class);
startActivity(intent);
finish();
}
},5000);
}
}
}