GoogleApiClient.ConnectionCallbacks

public interface GoogleApiClient.ConnectionCallbacks


Provides callbacks that are called when the client is connected or disconnected from the service. Most applications implement GoogleApiClient.ConnectionCallbacks#onConnected(Bundle) to start making requests.

Summary

Constants

default static final int

A suspension cause informing you that a peer device connection was lost.

default static final int

A suspension cause informing that the service has been killed.

Public methods

abstract void
onConnected(@Nullable Bundle connectionHint)

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

abstract void

Called when the client is temporarily in a disconnected state.

Constants

CAUSE_NETWORK_LOST

default static final int CAUSE_NETWORK_LOST = 2

A suspension cause informing you that a peer device connection was lost.

CAUSE_SERVICE_DISCONNECTED

default static final int CAUSE_SERVICE_DISCONNECTED = 1

A suspension cause informing that the service has been killed.

Public methods

onConnected

abstract void onConnected(@Nullable Bundle connectionHint)

After calling GoogleApiClient#connect(), this method will be invoked asynchronously when the connect request has successfully completed. After this callback, the application can make requests on other methods provided by the client and expect that no user intervention is required to call methods that use account and scopes provided to the client constructor.

Note that the contents of the connectionHint Bundle are defined by the specific services. Please see the documentation of the specific implementation of GoogleApiClient you are using for more information.

Parameters
@Nullable Bundle connectionHint

Bundle of data provided to clients by Google Play services. May be null if no content is provided by the service.

onConnectionSuspended

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 to re-enable them.

Parameters
int cause

The reason for the disconnection. Defined by constants CAUSE_*.