java.lang.Object | |
↳ | com.google.android.gms.common.api.GoogleApiClient.Builder |
Builder to configure a GoogleApiClient
.
Example:
GoogleApiClient client = new GoogleApiClient.Builder(this) .addApi(Plus.API) .addScope(Plus.SCOPE_PLUS_LOGIN) .setAccountName("users.account.name@gmail.com") .build(); client.connect();
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Builder to help construct the
GoogleApiClient object.
| |||||||||||
Builder to help construct the
GoogleApiClient object.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Specify which Apis are requested by your app.
| |||||||||||
Specify which Apis are requested by your app.
| |||||||||||
Specify which Apis should attempt to connect, but are not strictly required for your app.
| |||||||||||
Specify which Apis should attempt to connect, but are not strictly required for your app.
| |||||||||||
Registers a listener to receive connection events from this
GoogleApiClient .
| |||||||||||
Adds a listener to register to receive connection failed events from this
GoogleApiClient .
| |||||||||||
Specify the OAuth 2.0 scopes requested by your app.
| |||||||||||
Builds a new
GoogleApiClient object for communicating with the Google
APIs.
| |||||||||||
Enables automatic lifecycle management in a support library
FragmentActivity that
connects the client in onStart() and disconnects it in onStop() .
| |||||||||||
Specifies requesting of a server auth code for third party web server as part of
client connect() flow.
| |||||||||||
Specify an account name on the device that should be used.
| |||||||||||
Specifies the part of the screen at which games service popups (for example, "welcome
back" or "achievement unlocked" popups) will be displayed using gravity.
| |||||||||||
Sets a
Handler to indicate which thread to use when invoking callbacks.
| |||||||||||
Sets the
View to use as a content view for popups.
| |||||||||||
Specify that the default account should be used when connecting to services.
|
[Expand]
Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Builder to help construct the GoogleApiClient
object.
context | The context to use for the connection. |
---|
Builder to help construct the GoogleApiClient
object.
context | The context to use for the connection. |
---|---|
connectedListener | The listener where the results of the asynchronous
connect() call are delivered. |
connectionFailedListener | The listener which will be notified if the connection attempt fails. |
Specify which Apis should attempt to connect, but are not strictly required for your app.
The GoogleApiClient will try to connect to these Apis, but will not necessarily fail if
there are only errors when connecting to an unavailable Api added with this method.
See Api
for more information.
api | The Api requested by your app. |
---|---|
scopes | Scopes required by this API. |
Specify which Apis should attempt to connect, but are not strictly required for your app.
The GoogleApiClient will try to connect to these Apis, but will not necessarily fail if
there are only errors when connecting to an unavailable Api added with this method.
See Api
for more information.
api | The Api requested by your app. |
---|---|
scopes | Scopes required by this API. |
Registers a listener to receive connection events from this GoogleApiClient
.
Applications should balance calls to this method with calls to
unregisterConnectionCallbacks(ConnectionCallbacks)
to avoid leaking resources.
If the specified listener is already registered to receive connection events, this method will not add a duplicate entry for the same listener.
Note that the order of messages received here may not be stable, so clients should not rely on the order that multiple listeners receive events in.
listener | the listener where the results of the asynchronous connect() call
are delivered.
|
---|
Adds a listener to register to receive connection failed events from this
GoogleApiClient
. Applications should balance calls to this method with calls to
unregisterConnectionFailedListener(OnConnectionFailedListener)
to avoid leaking
resources.
If the specified listener is already registered to receive connection failed events, this method will not add a duplicate entry for the same listener.
Note that the order of messages received here may not be stable, so clients should not rely on the order that multiple listeners receive events in.
listener | the listener where the results of the asynchronous connect() call
are delivered.
|
---|
Builds a new GoogleApiClient
object for communicating with the Google
APIs.
GoogleApiClient
object.
Enables automatic lifecycle management in a support library FragmentActivity
that
connects the client in onStart()
and disconnects it in onStop()
.
ConnectionResult
has no resolution.
This eliminates most of the boiler plate associated with using GoogleApiClient
.
When using this option, build()
must be called from the main thread.fragmentActivity | The activity that uses the GoogleApiClient . For lifecycle management to
work correctly the activity must call its parent's onActivityResult(int, int, android.content.Intent) . |
---|---|
clientId | A non-negative identifier for this client. At any given time, only one
auto-managed client is allowed per id. To reuse an id you must first call stopAutoManage(FragmentActivity) on the previous client. |
unresolvedConnectionFailedListener | Called if the connection failed and there was no resolution or the user chose
not to complete the provided resolution. If this listener is called, the client
will no longer be auto-managed, and a new instance must be built. In the event
that the user chooses not to complete a resolution, the ConnectionResult
will have a status code of CANCELED . |
NullPointerException | if fragmentActivity is null |
---|---|
IllegalArgumentException | if clientId is negative. |
IllegalStateException | if clientId is already being auto-managed. |
Specifies requesting of a server auth code for third party web server as part of client connect() flow. This is useful for applications which have a web server component that need to access a Google API after the user has left the (Android) application.
If server auth code is requested, you will be given the server auth code in
onUploadServerAuthCode(String, String)
callback.
serverClientId | the 3rd party server client ID for offline access. |
---|---|
callbacks | the GoogleApiClient.ServerAuthCodeCallbacks delegate which will be called back
when communicating back to 3rd party web server is needed.
|
Specify an account name on the device that should be used. If this is never called, the client will use the current default account for Google Play services for this application.
accountName | The account name on the device that should be used by
GoogleApiClient .
|
---|
Specifies the part of the screen at which games service popups (for example, "welcome back" or "achievement unlocked" popups) will be displayed using gravity.
Default value is TOP
|CENTER_HORIZONTAL
.
gravityForPopups | The gravity which controls the placement of games service popups. |
---|
Sets a Handler
to indicate which thread to use when invoking callbacks. Will not
be used directly to handle callbacks. If this is not called then the application's main
thread will be used.
Sets the View
to use as a content view for popups.
viewForPopups | The view to use as a content view for popups. View cannot be null. |
---|
Specify that the default account should be used when connecting to services.