Reputation: 1615
I have a GoogleApiClient. I use this code:
GoogleApiClient client = new GoogleApiClient.Builder(this).addApi(Games.API).addScope(Games.SCOPE_GAMES).addApiIfAvailable(Wearable.API).addConnectionCallbacks(this).addOnConnectionFailedListener(this).build();
I have stored a boolean in SharedPrefs if the user wanted to connect with Google Play Games. If yes I call client.connect()
. But if not I still want, that the Wearable API is connected. How can I achieve, that the Wearable API will be always connected, but the Games API not.
Upvotes: 0
Views: 133
Reputation: 6635
Why not simply connect to the Games API conditionally, based on the SharedPreference?
GoogleApiClient.Builder bob = new GoogleApiClient.Builder(this)
.addApiIfAvailable(Wearable.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this);
if (settings.getBoolean("use_games", false)) {
bob.addApi(Games.API)
.addScope(Games.SCOPE_GAMES);
}
GoogleApiClient client = bob.build();
Based on your question, that seems like the obvious approach. Or am I missing something here?
Upvotes: 2