com.google.android.gms.auth.api.signin.GoogleSignInAccount Java Examples

The following examples show how to use com.google.android.gms.auth.api.signin.GoogleSignInAccount. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoginActivity.java    From TwrpBuilder with GNU General Public License v3.0 9 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == 1) {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        try {
            GoogleSignInAccount account = task.getResult(ApiException.class);
            firebaseAuthWithGoogle(account);
        } catch (ApiException e) {
            Log.w("TAG", "Google sign in failed", e);
            // ...
        }
    }
}
 
Example #2
Source File: AndroidGoogleDrive.java    From QtAndroidTools with MIT License 9 votes vote down vote up
public boolean authenticate(String AppName, String ScopeName)
{
    final GoogleSignInAccount SignInAccount = GoogleSignIn.getLastSignedInAccount(mActivityInstance);

    if(SignInAccount != null)
    {
        GoogleAccountCredential AccountCredential;
        Drive.Builder DriveBuilder;

        AccountCredential = GoogleAccountCredential.usingOAuth2(mActivityInstance, Collections.singleton(ScopeName));
        AccountCredential.setSelectedAccount(SignInAccount.getAccount());

        DriveBuilder = new Drive.Builder(AndroidHttp.newCompatibleTransport(), new GsonFactory(), AccountCredential);
        DriveBuilder.setApplicationName(AppName);
        mDriveService = DriveBuilder.build();

        return true;
    }

    Log.d(TAG, "You have to signin by select account before use this call!");
    return false;
}
 
Example #3
Source File: EventsController.java    From PGSGP with MIT License 9 votes vote down vote up
public void loadEvents() {
    GoogleSignInAccount googleSignInAccount = GoogleSignIn.getLastSignedInAccount(activity);
    if (connectionController.isConnected().first && googleSignInAccount != null) {
        Games.getEventsClient(activity, googleSignInAccount)
                .load(true)
                .addOnCompleteListener(new OnCompleteListener<AnnotatedData<EventBuffer>>() {
                    @Override
                    public void onComplete(@NonNull Task<AnnotatedData<EventBuffer>> task) {
                        if (task.isSuccessful() && task.getResult() != null) {
                            EventBuffer events = task.getResult().get();
                            if (events != null) {
                                JSONArray jsonArray = new JSONArray();
                                for (Event event : events) {
                                    jsonArray.put(eventInfoArray(event));
                                }
                                godotCallbacksUtils.invokeGodotCallback(GodotCallbacksUtils.EVENTS_LOADED, new Object[]{jsonArray.toString()});
                            } else {
                                godotCallbacksUtils.invokeGodotCallback(GodotCallbacksUtils.EVENTS_EMPTY, new Object[]{});
                            }
                        } else {
                            godotCallbacksUtils.invokeGodotCallback(GodotCallbacksUtils.EVENTS_LOADED_FAILED, new Object[]{});
                        }
                    }
                });
    } else {
        godotCallbacksUtils.invokeGodotCallback(GodotCallbacksUtils.EVENTS_LOADED_FAILED, new Object[]{});
    }
}
 
Example #4
Source File: AchievementsController.java    From PGSGP with MIT License 9 votes vote down vote up
public void incrementAchievement(String achievementName, int step) {
    GoogleSignInAccount googleSignInAccount = GoogleSignIn.getLastSignedInAccount(activity);
    if (connectionController.isConnected().first && googleSignInAccount != null) {
        Games.getAchievementsClient(activity, googleSignInAccount).increment(achievementName, step);
        godotCallbacksUtils.invokeGodotCallback(GodotCallbacksUtils.ACHIEVEMENT_INCREMENTED, new Object[]{achievementName});
    } else {
        godotCallbacksUtils.invokeGodotCallback(GodotCallbacksUtils.ACHIEVEMENT_INCREMENTED_FAILED, new Object[]{achievementName});
    }
}
 
Example #5
Source File: SignInActivity.java    From codelab-friendlychat-android with Apache License 2.0 8 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent in signIn()
    if (requestCode == RC_SIGN_IN) {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        try {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = task.getResult(ApiException.class);
            firebaseAuthWithGoogle(account);
        } catch (ApiException e) {
            // Google Sign In failed, update UI appropriately
            Log.w(TAG, "Google sign in failed", e);
        }
    }
}
 
Example #6
Source File: MainActivity.java    From android-credentials with Apache License 2.0 8 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Log.d(TAG, "onActivityResult:" + requestCode + ":" + resultCode + ":" + data);

    if (requestCode == RC_SIGN_IN) {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        handleGoogleSignIn(task);
    } else if (requestCode == RC_CREDENTIALS_READ) {
        mIsResolving = false;
        if (resultCode == RESULT_OK) {
            Credential credential = data.getParcelableExtra(Credential.EXTRA_KEY);
            handleCredential(credential);
        }
    } else if (requestCode == RC_CREDENTIALS_SAVE) {
        mIsResolving = false;
        if (resultCode == RESULT_OK) {
            Toast.makeText(this, "Saved", Toast.LENGTH_SHORT).show();
        } else {
            Log.w(TAG, "Credential save failed.");
        }
    }
}
 
Example #7
Source File: SignInActivity.java    From google-services with Apache License 2.0 8 votes vote down vote up
@Override
public void onStart() {
    super.onStart();

    // [START on_start_sign_in]
    // Check for existing Google Sign In account, if the user is already signed in
    // the GoogleSignInAccount will be non-null.
    GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
    updateUI(account);
    // [END on_start_sign_in]
}
 
Example #8
Source File: MainActivity.java    From Android-9-Development-Cookbook with MIT License 8 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == REQUEST_SIGN_IN) {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        try {
            GoogleSignInAccount account = task.getResult(ApiException.class);
            findViewById(R.id.signInButton).setVisibility(View.GONE);
            Toast.makeText(this, "Logged in:"+account.getDisplayName(), Toast.LENGTH_SHORT)
                    .show();
        } catch (ApiException e) {
            e.printStackTrace();
            Toast.makeText(this, "Sign in failed:"+e.getLocalizedMessage(), Toast.LENGTH_SHORT)
                    .show();
        }
    }
}
 
Example #9
Source File: AuthenticationManager.java    From ground-android with Apache License 2.0 7 votes vote down vote up
private void onActivityResult(ActivityResult activityResult) {
  // The Task returned from getSignedInAccountFromIntent is always completed, so no need to
  // attach a listener.
  try {
    Task<GoogleSignInAccount> googleSignInTask =
        GoogleSignIn.getSignedInAccountFromIntent(activityResult.getData());
    onGoogleSignIn(googleSignInTask.getResult(ApiException.class));
  } catch (ApiException e) {
    Log.w(TAG, "Sign in failed: " + e);
    signInState.onNext(new SignInState(e));
  }
}
 
Example #10
Source File: SignInActivityWithDrive.java    From google-services with Apache License 2.0 7 votes vote down vote up
@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) {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        handleSignInResult(task);
    }
}
 
Example #11
Source File: RNGoogleSigninModule.java    From google-signin with MIT License 7 votes vote down vote up
@Override
public void onActivityResult(Activity activity, final int requestCode, final int resultCode, final Intent intent) {
    if (requestCode == RC_SIGN_IN) {
        // The Task returned from this call is always completed, no need to attach a listener.
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(intent);
        handleSignInTaskResult(task);
    } else if (requestCode == REQUEST_CODE_RECOVER_AUTH) {
        if (resultCode == Activity.RESULT_OK) {
            rerunFailedAuthTokenTask();
        } else {
            promiseWrapper.reject(MODULE_NAME, "Failed authentication recovery attempt, probably user-rejected.");
        }
    }
}
 
Example #12
Source File: SignInActivity.java    From budgetto with MIT License 7 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == RC_SIGN_IN) {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        try {
            GoogleSignInAccount account = task.getResult(ApiException.class);
            firebaseAuthWithGoogle(account);
        } catch (ApiException e) {
            e.printStackTrace();
            hideProgressView();
            loginError("Google sign in failed.");
        }
    }
}
 
Example #13
Source File: GoogleProviderHandler.java    From capacitor-firebase-auth with MIT License 7 votes vote down vote up
@Override
public void fillResult(AuthCredential credential, JSObject jsResult) {
    GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this.plugin.getContext());
    if (account != null)  {
        jsResult.put("idToken", account.getIdToken());
    } else {
        Log.w(GOOGLE_TAG, "Ops, there was not last signed in account on google api.");
    }
}
 
Example #14
Source File: ShortyzActivity.java    From shortyz with GNU General Public License v3.0 6 votes vote down vote up
protected void signInSilently() {
	Log.d(TAG, "signInSilently()");

	mGoogleSignInClient.silentSignIn().addOnCompleteListener(this,
			new OnCompleteListener<GoogleSignInAccount>() {
				@Override
				public void onComplete(@NonNull Task<GoogleSignInAccount> task) {
					if (task.isSuccessful()) {
						Log.d(TAG, "signInSilently(): success");
						onConnected(task.getResult());
					} else {
						Log.d(TAG, "signInSilently(): failure", task.getException());
						onDisconnected();
					}
				}
			});
}
 
Example #15
Source File: MainActivity.java    From snippets-android with Apache License 2.0 6 votes vote down vote up
private void firebaseAuthWithPlayGames(GoogleSignInAccount acct) {
    Log.d(TAG, "firebaseAuthWithPlayGames:" + acct.getId());

    final FirebaseAuth auth = FirebaseAuth.getInstance();
    AuthCredential credential = PlayGamesAuthProvider.getCredential(acct.getServerAuthCode());
    auth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {
                        // Sign in success, update UI with the signed-in user's information
                        Log.d(TAG, "signInWithCredential:success");
                        FirebaseUser user = auth.getCurrentUser();
                        updateUI(user);
                    } else {
                        // If sign in fails, display a message to the user.
                        Log.w(TAG, "signInWithCredential:failure", task.getException());
                        Toast.makeText(MainActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                        updateUI(null);
                    }

                    // ...
                }
            });
}
 
Example #16
Source File: SignInActivity.java    From codelab-friendlychat-android with Apache License 2.0 6 votes vote down vote up
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());
    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mFirebaseAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInWithCredential", task.getException());
                        Toast.makeText(SignInActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    } else {
                        startActivity(new Intent(SignInActivity.this, MainActivity.class));
                        finish();
                    }
                }
            });
}
 
Example #17
Source File: MainActivity.java    From android-credentials with Apache License 2.0 6 votes vote down vote up
private void googleSilentSignIn() {
    // Try silent sign-in with Google Sign In API
    Task<GoogleSignInAccount> silentSignIn = mSignInClient.silentSignIn();

    if (silentSignIn.isComplete() && silentSignIn.isSuccessful()) {
        handleGoogleSignIn(silentSignIn);
        return;
    }

    showProgress();
    silentSignIn.addOnCompleteListener(new OnCompleteListener<GoogleSignInAccount>() {
        @Override
        public void onComplete(@NonNull Task<GoogleSignInAccount> task) {
            hideProgress();
            handleGoogleSignIn(task);
        }
    });
}
 
Example #18
Source File: GoogleLogin.java    From Android-Smart-Login with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data, SmartLoginConfig config) {
    ProgressDialog progress = ProgressDialog.show(config.getActivity(), "", config.getActivity().getString(R.string.getting_data), true);
    GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
    Log.d("GOOGLE SIGN IN", "handleSignInResult:" + result.isSuccess());
    if (result.isSuccess()) {
        // Signed in successfully, show authenticated UI.
        GoogleSignInAccount acct = result.getSignInAccount();
        SmartGoogleUser googleUser = UserUtil.populateGoogleUser(acct);
        // Save the user
        UserSessionManager.setUserSession(config.getActivity(), googleUser);
        config.getCallback().onLoginSuccess(googleUser);
        progress.dismiss();
    } else {
        Log.d("GOOGLE SIGN IN", "" + requestCode);
        // Signed out, show unauthenticated UI.
        progress.dismiss();
        config.getCallback().onLoginFailure(new SmartLoginException("Google login failed", LoginType.Google));
    }
}
 
Example #19
Source File: LoginActivity.java    From triviums with MIT License 6 votes vote down vote up
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    binding.signInButton.setVisibility(View.GONE);
    binding.progressBar.setVisibility(View.VISIBLE);

    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, task -> {
                if (task.isSuccessful()) {
                    viewModel.setLoggedIn(true);
                    // Sign in success, update UI with the signed-in user's information
                    binding.progressBar.setVisibility(View.GONE);
                } else {
                    // If sign in fails, display a message to the user.
                    Toast.makeText(LoginActivity.this, "Authentication failed.",
                            Toast.LENGTH_SHORT).show();
                }

            });
}
 
Example #20
Source File: EasyFirebaseAuth.java    From EasyFirebase with Apache License 2.0 6 votes vote down vote up
public EasyFirebaseAuth(GoogleApiClient googleApiClient) {
    mAuth = FirebaseAuth.getInstance();
    this.googleApiClient = googleApiClient;

    mAuthListener = new FirebaseAuth.AuthStateListener() {
        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            final FirebaseUser user = firebaseAuth.getCurrentUser();
            if (user != null) {
                if (firebaseUserSubscriber != null) {
                    firebaseUserSubscriber.onNext(new Pair<GoogleSignInAccount, FirebaseUser>(googleSignInAccount, user));
                    firebaseUserSubscriber.onCompleted();
                }
                if (loggedSubcriber != null) {
                    loggedSubcriber.onNext(user);
                }
                // User is signed in
                Log.d("TAG", "onAuthStateChanged:signed_in:" + user.getUid());
            } else {
                // User is signed out
                Log.d("TAG", "onAuthStateChanged:signed_out");
            }
        }
    };
}
 
Example #21
Source File: ServerAuthCodeActivity.java    From google-services with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == RC_GET_AUTH_CODE) {
        // [START get_auth_code]
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        try {
            GoogleSignInAccount account = task.getResult(ApiException.class);
            String authCode = account.getServerAuthCode();

            // Show signed-un UI
            updateUI(account);

            // TODO(developer): send code to server and exchange for access/refresh/ID tokens
        } catch (ApiException e) {
            Log.w(TAG, "Sign-in failed", e);
            updateUI(null);
        }
        // [END get_auth_code]
    }
}
 
Example #22
Source File: Loginactivity.java    From LuxVilla with Apache License 2.0 6 votes vote down vote up
@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);
        if (result.isSuccess()) {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = result.getSignInAccount();
            firebaseAuthWithGoogle(account);
        } else {
            linearLayout.setVisibility(View.VISIBLE);
            layoutprogressbar.setVisibility(View.GONE);
            Snackbar.make(linearLayout,"Ocorreu um erro ao conectar", Snackbar.LENGTH_LONG).show();
        }
    }
}
 
Example #23
Source File: FirebaseHelper.java    From UberClone with MIT License 6 votes vote down vote up
public void registerByGoogleAccount(final GoogleSignInAccount account){
    final User user=new User();
    users.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
            User post = dataSnapshot.child(account.getId()).getValue(User.class);

            if(post==null) showRegisterPhone(user, account);
            else loginSuccess();
        }

        @Override
        public void onCancelled(@NonNull DatabaseError databaseError) {

        }
    });
}
 
Example #24
Source File: PlayGamesPlugin.java    From play_games with MIT License 6 votes vote down vote up
private void handleSuccess(GoogleSignInAccount acc) {
    currentAccount = acc;
    PlayersClient playersClient = Games.getPlayersClient(registrar.activity(), currentAccount);
    playersClient.getCurrentPlayer().addOnSuccessListener(new OnSuccessListener<Player>() {
        @Override
        public void onSuccess(Player player) {
            Map<String, Object> successMap = new HashMap<>();
            successMap.put("type", "SUCCESS");
            successMap.put("id", player.getPlayerId());
            successMap.put("email", currentAccount.getEmail());
            successMap.put("displayName", player.getDisplayName());
            successMap.put("hiResImageUri", player.getHiResImageUri().toString());
            successMap.put("iconImageUri", player.getIconImageUri().toString());
            result(successMap);
        }
    }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(Exception e) {
            error("ERROR_FETCH_PLAYER_PROFILE", e);
        }
    });
}
 
Example #25
Source File: FireSignin.java    From Learning-Resources with MIT License 6 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    mCallbackManager.onActivityResult(requestCode, resultCode, data);

    if (requestCode == REQUESTCODE_SIGN_IN_GOOGLE) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {

            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = result.getSignInAccount();
            firebaseAuthWithGoogle(account);
        } else {
            mPrgrsbrMain.setVisibility(View.GONE);
            Snackbar.make(mCrdntrlyot, "Google authentication failed.", Snackbar.LENGTH_LONG).show();
        }
    }
}
 
Example #26
Source File: SignInBaseActivity.java    From Expert-Android-Programming with MIT License 6 votes vote down vote up
@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);
        if (result.isSuccess()) {
            // Google Sign In was successful, authenticate with FireBase
            GoogleSignInAccount account = result.getSignInAccount();
            firebaseAuthWithGoogle(account);
        }
    } else {
        callbackManager.onActivityResult(requestCode, resultCode, data);
    }
}
 
Example #27
Source File: SignInActivity.java    From budgetto with MIT License 6 votes vote down vote up
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {
                        FirebaseUser user = mAuth.getCurrentUser();
                        updateUI(user);
                    } else {
                        loginError("Firebase auth failed.");
                        hideProgressView();
                    }
                }
            });
}
 
Example #28
Source File: Fido2DemoActivity.java    From android-fido with Apache License 2.0 6 votes vote down vote up
private void handleSignInResult(GoogleSignInResult result) {
    Log.d(TAG, "handleSignInResult:" + result.isSuccess());
    Log.d(TAG, "sign in result: " + result.getStatus().toString());
    if (result.isSuccess()) {
        GoogleSignInAccount acct = result.getSignInAccount();
        saveAccountSignInStatus();
        Log.d(TAG, "account email" + acct.getEmail());
        Log.d(TAG, "account displayName" + acct.getDisplayName());
        Log.d(TAG, "account id" + acct.getId());
        Log.d(TAG, "account idToken" + acct.getIdToken());
        Log.d(TAG, "account scopes" + acct.getGrantedScopes());
    } else {
        clearAccountSignInStatus();
    }
    updateUI();
}
 
Example #29
Source File: RestApiActivity.java    From google-services with Apache License 2.0 6 votes vote down vote up
private void handleSignInResult(@NonNull Task<GoogleSignInAccount> completedTask) {
    Log.d(TAG, "handleSignInResult:" + completedTask.isSuccessful());

    try {
        GoogleSignInAccount account = completedTask.getResult(ApiException.class);
        updateUI(account);

        // Store the account from the result
        mAccount = account.getAccount();

        // Asynchronously access the People API for the account
        getContacts();
    } catch (ApiException e) {
        Log.w(TAG, "handleSignInResult:error", e);

        // Clear the local account
        mAccount = null;

        // Signed out, show unauthenticated UI.
        updateUI(null);
    }
}
 
Example #30
Source File: GoogleAccountsProvider.java    From science-journal with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isSignedIn() {
  GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(context);
  return account != null;
}