Android App Development | Lecture#36 | Hive Learners


Hello, dear Hive Learner, I hope you all are well. Yesterday we added the email verification to our sign-in activity. Today we will check if the user is login and is email verified on app start so that we can open the welcome screen. On the Welcome screen, we will show the login user email and username. Also, write the firebase signout code in the logout button and click listeners.

GitHub Link

Use this GitHub project to clone into your directory. The following lecture will constantly update it so you will never miss the latest code. Happy Coding!

What Should I Learn

  • Check If the user has already login
  • Check if the email is verified or not


  • Open the Welcome screen if the user sign-in and with a verified email


In we will add the check in onStart() override. We also learn all the overrides in our previous lectures. Declare and initialize the FirebaseAuth in the MainActivity.

Now add the override onStart() by pressing CTRL+O.

Now we will add the login in the onStart. It will open the Welcome Activity if a user is already login and if the email is verified.

    protected void onStart() {

        if (firebaseAuth.getCurrentUser() != null) {
            if (firebaseAuth.getCurrentUser().isEmailVerified()) {
                startActivity(new Intent(MainActivity.this, Welcome_Activity.class));

In the Welcome Activity, we will show the username. We will remove the SharedPreference code and add the FirebaseAuth code in Welcome Activity. First, we need to declare and initialize the FirebaseAuth then we can use it.

We used the custom dialog in the Welcome Activity logout button click listener. So we keep the code and only change the SharedPreference logout with the Firebase logout. We will also remove the ProgressDialog as there is no listener for firebase signout. It will sign out the user on the spot.

 logout_btn.setOnClickListener(v -> {

            Dialog custom_dialog = new Dialog(Welcome_Activity.this,;
            custom_dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

            MaterialButton no_btn = custom_dialog.findViewById(;
            MaterialButton yes_btn = custom_dialog.findViewById(;

            no_btn.setOnClickListener(v12 -> custom_dialog.cancel());

            yes_btn.setOnClickListener(v1 -> {
                startActivity(new Intent(Welcome_Activity.this, MainActivity.class));
                Toast.makeText(Welcome_Activity.this, "Logout Successful", Toast.LENGTH_SHORT).show();



Thank You


3 columns
2 columns
1 column