Firebase email authentication android

Firebase email authentication android is a process by which we can validate email address of the user. By this we can add a layer of the authentic user. Now a days its is quite useful. Manually if we need to validate the user we need to create a whole system to do so.

Like we need to deploy the database and api and send the email to authenticate user. Instead of doing all this we can just use the firebase email authentication method which saves a lot of time and dependency on the backend technologies.

So lets get started Firebase email authentication android

1- I hope you have already created the account on the firebase console if not you can go thorught this link.

2- Go to firebase console.

3- Go to Authentication and Sign-in Methods Enable email authentication then click save button.

Firebase email authentication

4- To send verification link from the android app create a email password field and submit button added in EmailVerificationActivity.

package com.example.sampleproject;

import androidx.annotation.NonNull;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;


public class EmailVerificationActivity extends AppCompatActivity {

private FirebaseAuth mAuth;
private Helper helper;

protected void onCreate(Bundle savedInstanceState) {
mAuth= FirebaseAuth.getInstance();
helper = new Helper(this);

((Button)findViewById( View.OnClickListener() {
public void onClick(View v) {
EditText email = (EditText)findViewById(;
String email_string = email.getText().toString();
EditText et_password = (EditText)findViewById(;
String pasword = et_password.getText().toString();

void createNewUser(String email,String password){
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(EmailVerificationActivity.this, new OnCompleteListener<AuthResult>() {
public void onComplete(@NonNull Task<AuthResult> task) {
// Toast.makeText(SignupMaterial.this, "createUserWithEmail:onComplete:" + task.isSuccessful(), Toast.LENGTH_SHORT).show();
// If sign in fails, helper.display a message to the admin. If sign in succeeds
// the auth state listener will be notified and logic to handle the
// signed in admin can be handled in the listener.

if (!task.isSuccessful()) {
// admin alreeady exists
// VerifyEmail();
helper.display("Email already exists");
} else {
// startActivity(new Intent(SignupActivity.this, ChangeMailActivity.class));
// finish();

private void VerifyEmail() {
final FirebaseUser user = mAuth.getCurrentUser();
if (user != null){
.addOnCompleteListener(EmailVerificationActivity.this, (OnCompleteListener) task -> {
// Re-enable button
if (task.isSuccessful()) {
FirebaseUser firebase_user = mAuth.getCurrentUser();
String firebase_uid=firebase_user.getUid();
helper.display("Email verification send");

} else {
Log.e("", "sendEmailVerification", task.getException());
helper.display("Failed to send verification email.");
}else {
// Toast.makeText(SignupMaterial.this, "null", Toast.LENGTH_SHORT).show();


on submit button email will be send.

Note: email should be unique.

email from firebase

Tagged : /