Skip to content Skip to sidebar Skip to footer

What Is The Googleapiclient Reconnect Policy After A Connection Gets Suspended?

The vague javadoc of GoogleApiClient tells us that: GoogleApiClient.ConnectionCallbacks.onConnectionSuspended is going to be : Called when the client is temporarily in a disconne

Solution 1:

I've rolled off the project, and code has changed in the meantime...

If I recall correctly, it tries to reconnect once, assuming that the connection was suspended due to a service crash (the most common cause). Then I would assume that it'd end up calling either onConnectionFailed() or onConnected(), but I wouldn't rely on that. I think you can verify this by killing the GMS process while your app is connected, but even if evidence shows that this is the case I still wouldn't rely on it unless it's documented.

I would not expect it to retry more than once if it fails to connect, or to ever stop if it connects and the service crashes again.

If I was building something that used the client and I wanted to be as defensive as possible, I wouldn't trust a suspended connection. I'd explicitly call disconnect() and connect() again to re-build the connection.

Post a Comment for "What Is The Googleapiclient Reconnect Policy After A Connection Gets Suspended?"