October 2018
Intermediate to advanced
464 pages
15h 17m
English
Google has made it relatively easy to add Google sign-in with their GoogleSignInClient and GoogleSignInOptions APIs. First, we create a GoogleSignInOptions object with the builder. This is where we specify the sign-in options we want, such as requesting email ID. Then, call the GoogleSignIn.getClient() method to get the GoogleSignInClient.
When the user clicks on the Google sign-in button (created with the com.google.android.gms.common.SignInButton class), we send an Intent for GoogleSignInApi to the handle. We process the result in onActivityResult(). If the sign-in was successful, we can get the account details. In our example, we just get the email, but additional information is available such as the following: