Login with Google in Android using Firebase

Firebase user authentication is a good approach for user authentication. In on of the tutorial we also cover Android Login and Signup with PHP MySQL .  In this tutorial we will learn about how to integrate Android Login with Google using Firebase.

Step -1: Add Firebase to your project 

  •  Go to Tools –> Click on Firebase
  • A dialog box will prompt from the left side. Choose Authentication and click on Email and password authentication.
  • Click on Connect your App to Firebase and Add Firebase Authentication to your App.
  • In the last step enable Sign in Method with Google from console .

Step -2: Add dependencies to your project: By adding Firebase authentication we have already added Google Play services and Authentication in dependencies. We only have to add Glide Library for getting image from url.

Step-3: Add internet permission

Step-4: Create Activity  Now create two activity I name it as GoogleLogin and HomeActivity.  In the first Activity  we have to create Button on click of that the user has to choose gmail id. Below is our layout file in which we are using round corner button. You can check Round corner button tutorial to create button like this.

Below is our code of GoogleLogin Activity. We are checking internet connection by isNetworkAvailable() method and firebaseAuthWithGoogle() to user login.

We are navigating to the second activity i.e HomeActivity from GoogleLogin Activity. in which we are showing user name, email and images. Below is our  HomeActivity.xml code.

We are passing user data such as user name, email  and image url from one activity to another activity we are getting data by using bundle and setting it into TextView and ImageView respectively. Below is our HomeActivity. java class.

Now run the App I hope it will run successfully. These are the demo images of our App.

This is all about Android Login with Google using Firebase.

If you have doubts or facing any problems please let me know in the comment box I will happy to help you. You can check other tutorials as well.

JSON Parsing and display into RecyclerView using Volley Library

Android Login and Signup with PHP MySQL

Parse JSON data into Spinner in Android

Android show current location in Google Map using Google Maps Android API

Youtube channel integration in Android using YoutubePlayerView API

Google Places Autocomplete Services using Google Places API

Reference:  Firebase authentication