@@ -71,9 +71,6 @@ public class MainActivity extends FragmentActivity implements
7171 // Client used to sign in with Google APIs
7272 private GoogleSignInClient mGoogleSignInClient ;
7373
74- // Account used to interact with Google APIs
75- private GoogleSignInAccount mGoogleSignInAccount ;
76-
7774 // Client variables
7875 private AchievementsClient mAchievementsClient ;
7976 private LeaderboardsClient mLeaderboardsClient ;
@@ -103,9 +100,6 @@ public void onCreate(Bundle savedInstanceState) {
103100 mGoogleSignInClient = GoogleSignIn .getClient (this ,
104101 new GoogleSignInOptions .Builder (GoogleSignInOptions .DEFAULT_GAMES_SIGN_IN ).build ());
105102
106- // mGoogleSignInAccount will be null until the user signs in.
107- mGoogleSignInAccount = null ;
108-
109103 // Create the fragments used by the UI.
110104 mMainMenuFragment = new MainMenuFragment ();
111105 mGameplayFragment = new GameplayFragment ();
@@ -133,7 +127,7 @@ private void switchToFragment(Fragment newFrag) {
133127 }
134128
135129 private boolean isSignedIn () {
136- return mGoogleSignInAccount != null ;
130+ return GoogleSignIn . getLastSignedInAccount ( this ) != null ;
137131 }
138132
139133 private void signInSilently () {
@@ -428,11 +422,9 @@ protected void onActivityResult(int requestCode, int resultCode, Intent intent)
428422 private void onConnected (GoogleSignInAccount googleSignInAccount ) {
429423 Log .d (TAG , "onConnected(): connected to Google APIs" );
430424
431- mGoogleSignInAccount = googleSignInAccount ;
432-
433- mAchievementsClient = Games .getAchievementsClient (this , mGoogleSignInAccount );
434- mLeaderboardsClient = Games .getLeaderboardsClient (this , mGoogleSignInAccount );
435- mPlayersClient = Games .getPlayersClient (this , mGoogleSignInAccount );
425+ mAchievementsClient = Games .getAchievementsClient (this , googleSignInAccount );
426+ mLeaderboardsClient = Games .getLeaderboardsClient (this , googleSignInAccount );
427+ mPlayersClient = Games .getPlayersClient (this , googleSignInAccount );
436428
437429 // Show sign-out button on main menu
438430 mMainMenuFragment .setShowSignInButton (false );
@@ -469,7 +461,6 @@ public void onComplete(@NonNull Task<Player> task) {
469461 private void onDisconnected () {
470462 Log .d (TAG , "onDisconnected()" );
471463
472- mGoogleSignInAccount = null ;
473464 mAchievementsClient = null ;
474465 mLeaderboardsClient = null ;
475466 mPlayersClient = null ;
0 commit comments