I have a wearable device that I\'m trying to connect to the GoogleApiClient but the callbacks are never called (onConnected, onConnectionSuspended or onConnectionFailed). Ev
Additionally, I noticed that if you try to do GoogleApiClient when user hasn't setup Google Play there can be a conflict connecting. (I just reset my device and that's what happened). So it's a good practice to test connection from GoogleApiClient using
mCredentialsApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
Or just check mCredentialsApiClient.isConnected() before peforming any task.
Oh wow, the answer is embarrassingly simple. I missed the part where in onStart()
you need to call mGoogleApiClient.connect()
.
You can call the connect and disconnect manually in the onStart and onStop lifecycle methods, or you can use the enableAutoManage feature.
mCredentialsApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.enableAutoManage(this, this)
.addApi(Auth.CREDENTIALS_API)
.build();