android – GoogleApiClient onConnectionSuspended , should i call mGoogleApiClient.connect() again?-ThrowExceptions

Exception or error:

I am using GoogleApiClient in a service to request fused location updates. Every thing is working correctly, but sometimes the connection is suspended and onConnectionSuspended is called.

public void onCreate() {
    mGoogleApiClient = new GoogleApiClient.Builder(this) // this is a Context
    .addConnectionCallbacks(this)  // this is a [GoogleApiClient.ConnectionCallbacks][1]
    .addOnConnectionFailedListener(this) //



public void onConnectionSuspended(int arg0) {

    // what should i do here ? should i call mGoogleApiClient.connect() again ? ? 


In the link above (ConnectionCallback doc) it says :

Applications should disable UI components that require the service, and wait for a call to onConnected(Bundle) to re-enable them.

But how this call to onConnected will happen ? should i call mGoogleApiClient.connect() again ? or the mGoogleApiClient will continue trying to connect even after a connection suspension ?

How to solve:

GoogleApiClient will automatically try to reconnect. You do not need to call connect() again.


The onConnected() doc says the follwing:

After calling connect(), this method will be invoked asynchronously when the connect request has successfully completed.

This implies that you have to call connect() otherwise onConnected() won’t be called.

Leave a Reply

Your email address will not be published. Required fields are marked *