GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail() .build();
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient); startActivityForResult(signInIntent, RC_SIGN_IN);
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...); if (requestCode == RC_SIGN_IN) { GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); handleSignInResult(result); } }
OptionalPendingResult opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
if (pendingResult.isDone()) { doStuffWith(pendingResult.get()); } else { // There's no immediate result ready, displays some progress indicator and waits for the // async callback. showProgressIndicator(); pendingResult.setResultCallback(new ResultCallback() { @Override public void onResult(@NonNull GoogleSignInResult result) { updateButtonsAndStatusFromSignInResult(result); hideProgressIndicator(); } }); }