Adding Firebase functionality in your app | Part 2 Creating Firebase Authentication

Introduction:
In this post, we will create a Login and Registration Page with Firebase authentication, we will accept the name, email, password of the user and register the user with the Firebase auth library.

Implementation:

  1. First, we need to enable authentication for our project, go to the Firebase console, select Authentication from the left panel and then sign-in method, enable email method.
  2. In AS, go-to the assistant, in the right panel, select Authentication, click connect to Firebase, it will be in green when connected, second select Add Authentication to the project, Accept changes and finish.
  3. Now you can start coding.
  4. Create an Empty Activity, named as SignUp
  5. Go to SignUp.xml and add the following XML.

The XML file defines three EditText for user input and Button.

Add the following java code to read the input and create an account with the Firebase


If everything is done correctly, you would be able to create an account with your email, when created check the Firebase console user section and you'll see a new account added.
Now let's implement Login Page

Create a new activity, named SignIn
Go to layout_signin.xml and add the following code:

Here we have created two input fields to accept email and password
Add the following java code in SignIn.java

Once, done you can view the Toast to see whether it works or not.
When you launch the app, you have to enter email and password every time to reduce that work, you can do the following in the first activity in your app, in my case, it is SignIn.java


If you have any doubts, please comment in the section below.

Popular posts from this blog

Audio de-noising using Python (Wavelets)

Using FFMPEG to trim your videos

Converting HTML5 Game for Android | 2 Methods