O'Reilly logo

Firebase Cookbook by Houssem Yahiaoui

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

To save you the hassle of creating the connection button and wiring the button and metadata, Firebase offers the powerful Firebase UI for Android, where it will help us create the basic UI and wire up everything for us out of the box. So let's see how we can make it happen.

  1. In your login activity, add the following variable declarations: 
       private static final int RC_SIGN_IN = 17;       FirebaseAuth auth;
  1. Next, in your onCreate() method, add the following : 
      auth = FirebaseAuth.getInstance();      if(auth.getCurrentUser() != null) {     Log.d("Auth", "Logged in successfully");     } else {      startActivityForResult(            AuthUI.getInstance()                    .createSignInIntentBuilder()                    .setAvailableProviders(                      Arrays.asList(                             new     AuthUI.IdpConfig.Builder(AuthUI. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required