Firebase Authentication – Send Reset Password Email / Forgot Password | Android

In previous post, we have known way to implement Sign up, Sign in/out, Verify Email. Today, we continue to take a look at way to send Reset Password Email in case User forgot Password.

*Note: This tutorial bases on code in related post:
Firebase Authentication – How to Sign Up, Sign In, Sign Out, Verify Email | Android

We just add an Activity to App for handling Reset Password Email and some statements to old code for logic.

I. Way to do

1. Add Firebase Auth to Android App

Read Firebase Authentication – Sign Up, Sign In, Sign Out, Verify Email and follow steps to enable and implement Firebase Auth in your Android App.

2. Send a password reset email

With the sendPasswordResetEmail() method:

We can customize the email template in Firebase console:
firebase-auth-email-password-mail-template-reset

II. Practice

1. Goal

We will build an Android App that can:
– create Account, sign in/sign out, send email verification.
– display current status/user information with verified email status.
(all things above are from previous tutorial)
– send reset password email in case user forgot password.

firebase-auth-email-password-reset-mail-demo

2. Technology

– Gradle 2.3.3
– Android Studio 2.x
– Firebase Android SDK 11.x

3. Project Structure

firebase-auth-email-password-reset-mail-structure

4. Step by step
4.1 Create Android Project

– Generate new Android Project with package com.javasampleapproach.firebaseauth.
build.gradle (project-level):

build.gradle (App-level):

4.2 Create Firebase Project & Add Firebase Config file

– Follow this guide to generate google-services.json file and move it into your Android App root directory. You don’t need to have SHA-1 Key in this example, just leave it blank.

– Make sure that package_name in google-services.json has a correct value according to:
+ applicationId in build.gradle (App-level).
+ package in AndroidManifest.xml.
In this case, it is com.javasampleapproach.firebaseauth.

4.3 Enabling Firebase Auth

Go to Your Firebase Project Console -> Authentication -> SIGN-IN METHOD -> Enable Email/Password:
firebaseauth-enable-email

4.4 LoginActivity

4.5 ResetPasswordActivity

4.6 Set main launcher activity

Open AndroidManifest.xml:
– make the LoginActivity.java as launcher activity (set it as the first screen).
– add ResetPasswordActivity as activity.

4.7 Run & Check result

– Use Android Studio, build and Run your Android App.

– Click on Forgot your password?, then fill in Email and click on RESET PASSWORD button:
firebase-auth-email-password-reset-mail-result-app

– Check your email:
firebase-auth-email-password-reset-mail-result-mail

– Follow instruction, click on the link inside, the browser shows a dialog, enter your new password:
firebase-auth-email-password-reset-mail-result-web-1

– The result:
firebase-auth-email-password-reset-mail-result-web-2

III. Source code

FirebaseAuth-withResetMail-Demo

By JavaSampleApproach | August 4, 2017.


Related Posts


1 thought on “Firebase Authentication – Send Reset Password Email / Forgot Password | Android”

  1. I just ought to tell you which you have written an exceptional and distinctive post that I really enjoyed reading. Im fascinated by how nicely you laid out your material and presented your views. Thank you.

Got Something To Say:

Your email address will not be published. Required fields are marked *

*