Welcome, friends, in this post I’ll show you how to make contact with FirebaseUI. Firebase offers many authentication possibilities. I will explain the Firebase user interface for e-mail and password login here. Then let’s get started.

Why should I use FirebaseUI for authentication?

FirebaseUI is an open source library, you can also customize it with open source. It excludes model code and promotes best practices for androids in terms of user experience and safety. FirebaseUI includes a simple click to activate and restore users.

Connect your application to the Firebasedatabase .

Let’s open the Android Studio and create a new Android project with an empty action template. I’ll take the name of the package here com.firebaseauthenticationuexample. Once the project has been created, connect your request to the database. Follow this article to create a project on the Firebase console.

Add a new splash class in the build.gradle project

Open build.gradle at project level and add the line below.

/Add this line
Classpath ‘com.google.gms:google-services:4.3.2’.

Adding a new plugin for build.gradle at application level

Open the build.gradle plugin and google services at application level by adding this line.

// Add this line
Application plugin: ‘com.google.gms.google-services’.

Automatic dependency of the Firebase user interface added to the same classification file at apple level

The Firebase UI library must perform an automatic start by email.

Execution com.firebaseui:firebase-ui-auth:4.3.1.

After adding the project synchronization, make sure everything works properly.

Enable email and password authentication on the Firebase console.

Go to the Firebase console and enable email verification. Go to the Authentication option in the left pane. After opening the authentication, go to the login area and activate the password to log in via e-mail.

Creation Login activity

I’m creating a new event with a layout file. Here I add a button to start the connection for demonstration purposes only. Let’s go to the layout file and add the Login button as shown below.

 

 

Let’s go to LoginActivity.

Before logging in, make sure that your user has not already logged in to LoginActivity during the previous session.

FirebaseAuth auth = FirebaseAuth.getInstance();
as (auth.getCurrentUser() != null) {
// already signed in
} otherwise {
// not signed in
}.

Create and start recording intentions

If the user is not logged in, the login process is started by creating an automatic request. You can specify the URL of the service and add a link to it, as well as customize the theme. You have to create and manage such a registration system.

// Authentication Provider Selection
Provider List = Arrays.asList(
new AuthUI.IdpConfig.EmailBuilder().build()) ;

// Creation and execution of a custom registry
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(provider)
.build(),
RC_SIGN_IN) ;

Verification of the Performance Response Code

@ Overwrite
protected void onActivityResult (int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// RC_SIGN_IN is the code of the request you passed to
as (requestCode == 1234) {

// Successful connection to
as (resultCode == RESULT_OK) {
// Successful connection to
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
Toast.makeText(getApplicationContext(), Successful connection, Toast.LENGTH_SHORT).
.show();
startMainActivity(user);
}
} otherwise {
// Connection failed. If the answer is zero, the user cancels the connection by clicking the Back button. Otherwise, check
// response.getError().getErrorCode() and process the error.
Toast.makeText(getApplicationContext(), cannot connect, Toast.LENGTH_SHORT).show();
}
}

Finally, the source code of the connection actions is as follows.

package com.firebaseauthentificationuiexample ;

Import android.content.Context; import android.content.intentional; import android.os.bundle; import android.view.view; import android.widget.Button; import android.widget.Toast; import androidx.annotation.annotation Null; import androidx.appcompat.appCompatActivity; import com.firebase.ui.auth.AuthUI; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.auth.FirebaseUser; import java.util.Arrays; import java util.List ;

The public class LoginActivity expands AppCompatActivity {
private static end int RC_SIGN_IN = 1234 ;

public static null startActivity (context) {
Intention = new intention (context, LoginActivity.class);
context.startActivity (intention);
}

Write
protected blank onCreate(storedInstanceState bundle) {
super.onCreate(storedInstanceState);
setContentView(R.layout.activity_login) ;

// Find View
buttonSignIn = findViewById(R.id.buttonSignIn);
// Click listener
buttonSignIn.setOnClickListener(new view).OnClickListener() {
@Stand a public void onClick(view) {
FirebaseAuth auth = FirebaseAuth.getInstance();
if (auth.getCurrentUser()) != null) {
Toast.makeText(getApplicationContext(), user already registered, must first log out,
Toast.LENGTH_SHORT).show();
// already registered in
} otherwise {
// select authentication provider
list provider = Arrays.asList(
new AuthUI.IdpConfig.EmailBuilder().build() ) ;

// Deliberately create a registry and enter ActivityForResult(AuthUI.getInstance().createSignInIntentBuilder().setAvailableProviders(ISPs).build(),RC_SIGN_IN);}}}}}}}.

@ Overwrite
protected void onActivityResult (int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// RC_SIGN_IN is the code of the request you passed to
as (requestCode == 1234) {

// Successful connection
as (resultCode == RESULT_OK) {
// Successful connection
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
Toast.makeText(getApplicationContext(), Successful connection, Toast.LENGTH_SHORT).
.show();
startMainActivity(user);
}
} otherwise {
// Connection failed. If the answer is zero, the user cancels the connection by clicking the Back button. Otherwise, check
// response.getError().getErrorCode() and process the error.
Toast.makeText(getApplicationContext(), cannot connect, Toast.LENGTH_SHORT).show();
}
}

private void startMainActivity(FirebaseUser user) {if (user != invalid) {MainActivity.startActivity(this, user.getDisplayName());finish();}}}}

Execution of main activitySystem logout

Your registration is complete. Now I’m gonna talk to you about getting fired. Open the presentation file of the main activity, add a button to log out.

 

Open the main file with the source code for activity.

The Firebase Autosigning provider’s output reminds you of onComplete. as shown below.

package com.firebaseauthentificationuiexample ;

Import android.content.Context;
import android.content.intentional;
import android.os.bundle;
import android.view.view;
import android.widget.button;
import android.widget.textView;
import android.widget.textToasts;
import androidx.annotation.NonNull;
import com.google.androidx.appcompat.appCompatActivity;
import com.firebase.ui.auth.AuthUI;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.onCompleteListener ;

The MainActivity public class expands AppCompatActivity {
private static endpoint ARG_NAME = username ;

public static void startActivity (context, string username) {
Intention = new intention (context, MainActivity.class);
intent.putExtra(ARG_NAME, username);
context.startActivity(intent);
}

Write
protected blank onCreate(storedInstanceState bundle) {
super.onCreate(storedInstanceState);
setContentView(R.layout.activity_main) ;

text rendering textView = findViewById(R.id.textView);
if (getIntent().hasExtra(ARG_NAME)) {
textView.setText(string.format(Welcome – %s, getIntent().getStringExtra(ARG_NAME))));
}.

Logout = findViewById(R.id.buttonLogout);
logout.setOnClickListener(new view.OnClickListener() {
@Overwrite public blank click onclick(show view) {
AuthUI.getInstance()
.signOut(MainActivity).this)
.addOnCompleteListener(new OnCompleteListener() {
public void onComplete(@NonNull task task))). {
// user is now logged out
Toast.makeText(getApplicationContext(), user is logged out …, Toast.LENGTH_SHORT)
.show() ;
startLoginActivity() ;
}
}) ;
}
}) ;
}.

private void startLoginActivity() {
LoginActivity.startActivity(MainActivity.this);
finish();
}
}.

With this tutorial on the Android application, we learned the firebaseui for email authentication I hope it will help you Help me by sharing this message with all your friends who are learning the development of the Android application.

Remains connected

If you want to stay in touch and receive e-mails when I write new articles on my blog, follow me on Facebook or subscribe to our site. Recording takes only about 10 seconds.

However, if you have any questions, please leave your comments below.

high performance coach salary,performance coach certification,high performing coach,performance coaching model,benefits of life coaching,how to become a business performance coach,mindset niche,mindset coaching services,success mindset coaching,mindset coaching templates,mindset coach website,mindset transformation coach,why do i need an executive coach,hire a leadership coach,why do companies hire executive coaches,executive coach hire,disadvantages of life coaching,why life coaching works,why everyone needs a life coach,facts about life coaching,benefits of having a coach,who is a life coach,benefits of hiring a life coach,benefits of hiring a coach,benefits of business coaching,why hire a business coach,what are the benefits of coaching and mentoring,benefits of coaching to the coach,benefits of being a life coach

You May Also Like

How to Enter Recovery Mode on Posh Orion MAX X550 Phone

Here is a complete guide on how to activate the recovery mode…

How To Reset Canon IP2770/iP2700 Printer 2020

Reset a Canon printer for iP2770 / iP2700 2020 – Although Canon…

PSU Tier List 2020: 5 Best Power Supply Unit – Buying Guide

The best paired power supply should always be at the top of…

Javascript Regular Expression – Linux Hint

Many programmers are familiar with the idea that a regular expression is…