0

I'm calling GoogleApiClient into a Service. The first time the service is launched, onConnected() is called. Then the service is stopped via stopSelf() and restarted so mGoogleApiClient (null) is build again:

mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Nearby.CONNECTIONS_API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();   

then :

mGoogleApiClient.connect()

result :

NearbyDiscoveryService: onConnectionFailed :: ConnectionResult{statusCode=UNKNOWN_ERROR_CODE(8050), resolution=null, message=null}

Any idea what's the problem ? Google tells nothing about error code 8050 (related to Android) !

HKoncept
  • 153
  • 2
  • 8

1 Answers1

0

I just found the problem. I must close the GoogleApiClient's connection before calling stopSelf():

//[...]

if( isDiscovering() ) {
    stopDiscovering();
}

if (!isAdvertising()) {
    getGoogleApiClient().disconnect();
    stopSelf();
}

//[...]
HKoncept
  • 153
  • 2
  • 8