2

Docs say this:

public abstract void onConnectionSuspended (int cause)

Called when the client is temporarily in a disconnected state. This can happen if there is a problem with the remote service (e.g. a crash or resource problem causes it to be killed by the system). When called, all requests have been canceled and no outstanding listeners will be executed. GoogleApiClient will automatically attempt to restore the connection. Applications should disable UI components that require the service, and wait for a call to onConnected(Bundle) to re-enable them.

I can't cause it to happen in order to investigate how to deal with it. I tried to disconnect from the Internet, but it's not the callback that gets called (onConnectionFailed gets called instead).

Sure it says I should disable UI components, but for how long does it get handled? Will "onConnected" be called shortly after, and always be called after it?

What if I create an activity that all its purpose is to connect to Google Drive? Should it close itself when it reaches onConnectionSuspended ? Or should it ignore it, as soon it will succeed to connect?

Also, as it is called "onConnectionSuspended", does it mean all other callbacks are quite instantaneous ?

android developer
  • 114,585
  • 152
  • 739
  • 1,270

1 Answers1

1

You should've gotten the *onConnectionSuspended* callback before *onConnectionFailed* was called. A similar issue indicates that onConnectionSuspended will be triggered when your app was disconnected on Google Play Services. A force stop/kill of the Google Play Service can trigger the callback, and after that - onConnectionFailed should be called next.

Community
  • 1
  • 1
Android Enthusiast
  • 4,826
  • 2
  • 15
  • 30