Android App Development | Lecture#36 | Hive Learners

in Hive Learners โ€ข 4 months ago


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


Sort: ย 

Good check

You can earn passive income by delegation of tribe tokens to "The Cartel".

Click this banner to join "The Cartel" discord server to know more.


You have received a 1UP from @gwajnberg!

The @oneup-cartel will soon upvote you with:
And they will bring !PIZZA ๐Ÿ•.

Learn more about our delegation service to earn daily rewards. Join the Cartel on Discord.

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support.ย 

Congratulations @faisalamin! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s):

You received more than 25000 upvotes.
Your next target is to reach 30000 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out the last post from @hivebuzz:

Hive Power Up Month Challenge 2022-07 - Winners List
The 8th edition of the Hive Power Up Month starts today!
Hive Power Up Day - August 1st 2022