Android Tutorial | Firebase User Registration | Part 5

in #utopian-io7 years ago (edited)

Android is a mobile operating system developed by Google, based on a modified version of the Linux kernel and other open source software and designed primarily for touchscreen mobile devices such as smartphones and tablets. In addition, Google has further developed Android TV for televisions, Android Auto for cars, and Android Wear for wrist watches, each with a specialized user interface. Variants of Android are also used on game consoles, digital cameras, PCs and other electronics. Android provides a rich application framework that allows you to build innovative apps and games for mobile devices in a Java language environment.
Source
Source 2


resource-card-default-android.jpg

Image Source


Useful Links

Android Developer

Android Open Source Project

Firebase Console


What Will I Learn?


Requirements


Difficulty

  • Intermediate

Curriculum

Android Tutorial | Google Text Recognition API | Part 1

Android Tutorial | Firebase User Registration | Part 2

Android Tutorial | Firebase User Registration | Part 3

Android Tutorial | Firebase User Registration | Part 4


Tutorial Contents

In this tutorial, I will continue where we left off in the previous tutorial. In previous lessons we have prepared our register and login pages. We did our registration process with Firebase. For our login process, we wrote our "userLogin" function.

In our "userLogin" function we had our edit texts, e-mail and password control. Now, firstly we will do login process with Firebase on the "userLogin" function.

I will do a "Progress Dialog " definition first to show the login user screen when the login button is pressed.

Code:

import android.app.ProgressDialog;

ProgressDialog progressDialog;

progressDialog = new ProgressDialog(this);

1.png

Now I will define the message and display the progressDialog.

Code:

progressDialog.setMessage("Login user...");
progressDialog.show();

2.png

I will now define Firebase object. And I'll write the "getInstance" method on our "onCreate" method so that it can run when our app runs.

Code:

import com.google.firebase.auth.FirebaseAuth;

FirebaseAuth firebaseAuth;

firebaseAuth = FirebaseAuth.getInstance();

3.png

Now we have integrated FireBase to our login activity, we can do our login process. For this we will use FireBase's "signInWithEmailAndPassword" method.

Code:

        firebaseAuth.signInWithEmailAndPassword(email,pass).addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
            @Override
            public void onComplete(@NonNull Task<AuthResult> task) {
                progressDialog.dismiss();
                
            }
        });

Yes, I created our "signInWithEmailAndPassword" method with our email and pass inputs and created our onComplete listener.

4.png

And I did progressDialog dismiss. (Login user...)

Now I write if the task is successful, show login successful toast message else show login failed toast message.

Code:

                if (task.isSuccessful()){
                    Toast.makeText(LoginActivity.this,"Login successfully", Toast.LENGTH_LONG).show();
                }else{
                    Toast.makeText(LoginActivity.this,"Could not login. Please try again.", Toast.LENGTH_LONG).show();
                }

5.png

So we have successfully completed our entry process. All you need to do open the profile page is to redirect the activity in the "task.isSuccessful" section.


We came to the end of our Part 5 tutorial. Thank you for your attention.




Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

indentaion of those code's are awesome.

Your contribution cannot be approved because it does not follow the Utopian Rules.

  • You must include the entire tutorial in the Utopian post. Plz not separate into several chapters,which i think it should be merged as a complete tutorial

You can contact us on Discord.
[utopian-moderator]

Your Post Has Been Featured on @Resteemable!
Feature any Steemit post using resteemit.com!
How It Works:
1. Take Any Steemit URL
2. Erase https://
3. Type re
Get Featured Instantly � Featured Posts are voted every 2.4hrs
Join the Curation Team Here | Vote Resteemable for Witness

Coin Marketplace

STEEM 0.17
TRX 0.15
JST 0.028
BTC 62014.91
ETH 2410.27
USDT 1.00
SBD 2.50