0

I'm trying to implement the saved games codes, I can save and load without problems, all the data is OK. But I when I connect with Google, the code connect with a default account. I try to use account picker and use the returned mail but the account was the same, same data. I need select the account or my code is useless.

This is my connect code:

public static void conectarGoogle(final FragmentActivity a) {
    GoogleApiClient.ConnectionCallbacks connectionCallbacks = new GoogleApiClient.ConnectionCallbacks() {
        @Override
        public void onConnected(@Nullable Bundle bundle) {
            Log.d(TAG,"conected");
        }

        @Override
        public void onConnectionSuspended(int i) {
            mGoogleApiClient.connect();
        }
    };

    GoogleApiClient.OnConnectionFailedListener cfl = new GoogleApiClient.OnConnectionFailedListener() {
        @Override
        public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
            Log.d(TAG,"failed="+connectionResult.toString());
            mIsResolving = BaseGameUtils.resolveConnectionFailure(a, mGoogleApiClient, connectionResult, RC_SIGN_IN, a.getString(R.string.signin_other_error));
        }
    };
    mGoogleApiClient = new GoogleApiClient.Builder(a)
            .addConnectionCallbacks(connectionCallbacks)
            .addOnConnectionFailedListener(cfl)
            .addApi(Games.API)
            .addScope(Games.SCOPE_GAMES)
            .addScope(Drive.SCOPE_APPFOLDER)
            .setViewForPopups(a.findViewById(android.R.id.content))
            .build();
    mGoogleApiClient.connect();
}

public static void desconectarGoogle(){
    if(mGoogleApiClient!=null && isSignedIn()) {
        mGoogleApiClient.disconnect();
    }
}

I need help for this problem. I use this code in mainactivity and preferencesactivity and cant select the account for save the progress.

  • The default account use the marchinglord2524 name.
  • The Games.API dont left add Auth.GOOGLE_SIGN_IN_API.
halfer
  • 19,824
  • 17
  • 99
  • 186
  • If you choose any account once, application goes with that account. If you clear app data or remove and reinstall app, you can choose an account. – Batuhan Coşkun Dec 27 '16 at 09:10
  • and if i want swipe the account? i never choose any account, google do this for me and is imposible i cant full disconnect and connect in other account. – Adrián Pastoriza Dec 27 '16 at 09:26
  • 1
    Try that `mGoogleApiClient.clearDefaultAccountAndReconnect();` from http://stackoverflow.com/questions/21610239/how-do-i-switch-accounts-under-the-new-google-drive-android-api – Batuhan Coşkun Dec 27 '16 at 09:29
  • i use the cleardefault and connect with the same account without left me select a new account. – Adrián Pastoriza Dec 27 '16 at 09:35
  • Note that questions here are either solved or not solved. We do not use [solved] title edits or put solutions in answers. Please remember that questions and answers are meant to be preserved in a state that makes them useful for future readers. I have moved the solution to an answer box. If you have a related question, would you ask another question? You can hyperlink to this question if the context is the same. Thank you. – halfer Dec 27 '16 at 22:53

1 Answers1

0

(Posted on behalf of the OP).

I don't know why, but I have in my device a default user, I clear the data on my Google Play Services and now I use my user: saved games documentation.

halfer
  • 19,824
  • 17
  • 99
  • 186