1

In my app some Google APIs are optional. (In this case the Games API.)

In my settings activity, the user can choose to not signin into Google Games. There I call

Games.signOut(mGoogleApiClient);
googleApiClient.disconnect();
googleApiClient = createGoogleApiClientWithoutGames();
googleApiClient.connect();

createGoogleApiClientWithoutGames method creates a new GoogleApiClient that does not use the Games API and corresponding scopes.

  1. Is this the correct way to remove api and scope from the client?

  2. How can I make sure that the googleApiClient of other activities (that are not yet destroyed) don't use the Games API? Currently, when returning from the settings activity, the client is connecting in onStart() using the current client configuration (with Games). Send a local broadcast message and recreate the client as well?

friedger
  • 645
  • 7
  • 21

1 Answers1

1

I am using a status variable to check in onStart() whether the current client in the MainActivity uses the correct apis. If not I recreate it before connecting.

The full source code is available at https://github.com/friedger/google-api-client-example

friedger
  • 645
  • 7
  • 21