Quicknav Quicknav
Links

- Google Play Developer Console
- Android Developers Blog
- About Android

Android Sites

- Android.com
- Android Developers
- Android Open Source Project

close

- - Get Started
  - Style
  - Patterns
  - Building Blocks
  - Downloads
  - Videos
- - Training
  - API Guides
  - Reference
  - Tools
    - Get the SDK
  - Google Services
- - Google Play
  - Publishing
  - Promoting
  - App Quality
  - Spotlight
  - Open Distribution

## Results

Loading...
Summary: Ctors | Methods | Inherited Methods | [Expand All]
public static final class

# GamesClient.Builder

extends Object

java.lang.Object
↳ | com.google.android.gms.games.GamesClient.Builder

This class is deprecated.
See `GoogleApiClient.Builder`.

## Class Overview

Builder class for GamesClient.

## Summary

Public Constructors
| GamesClient.Builder(Context context, GooglePlayServicesClient.ConnectionCallbacks connectedListener, GooglePlayServicesClient.OnConnectionFailedListener connectionFailedListener) Create a new Builder object to be used to build a corresponding GamesClient object.

Public Methods
GamesClient | create() Creates a new GamesClient object to be used to communicate with the games service, requesting all of the scopes passed in.
GamesClient.Builder | setAccountName(String accountName) Specify an account name on the device that should be used.
GamesClient.Builder | setGravityForPopups(int gravity) Specifies the part of the screen at which games service popups (for example, "welcome back" or "achievement unlocked" popups) will be displayed using gravity.
GamesClient.Builder | setScopes(String... scopes) Set the scopes to use when building the GamesClient object.
GamesClient.Builder | setShowConnectingPopup(boolean showConnectingPopup) Sets whether a "connecting" popup should be displayed automatically at the start of the sign-in flow.
GamesClient.Builder | setShowConnectingPopup(boolean showConnectingPopup, int gravity) Sets whether a "connecting" popup should be displayed automatically at the start of the sign-in flow.
GamesClient.Builder | setViewForPopups(View gamesContentView) Sets the `View` to use as a content view for popups.

[Expand] Inherited Methods

From class java.lang.Object

Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)

## Public Constructors

#### public GamesClient.Builder (Context context, GooglePlayServicesClient.ConnectionCallbacks connectedListener, GooglePlayServicesClient.OnConnectionFailedListener connectionFailedListener)

Create a new Builder object to be used to build a corresponding GamesClient object.

##### Parameters

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.

## Public Methods

#### public GamesClient create ()

Creates a new GamesClient object to be used to communicate with the games service, requesting all of the scopes passed in.

This method should be called from `onCreate(android.os.Bundle)` or `onActivityCreated(android.os.Bundle)`.

The object is not usable until after the asynchronous `connect()` method has been called and your listener's `onConnected(Bundle)` method is called. Note that the `ConnectionCallbacks` provided here will always receive callbacks before any subsequently registered connection listeners.

When your application is done using this client it must call `disconnect()`, even if the async result from `connect()` has not yet been delivered.

The typical pattern is to instantiate this object in your Activity's `onCreate(Bundle)` method and then call `connect()` in `onStart()` and `disconnect()` from `onStop()` regardless of the state.

##### Returns

- The GamesClient object.

#### public GamesClient.Builder setAccountName (String accountName)

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 Games for this application.

##### Parameters

accountName | The account name on the device that should be used by this `GamesClient`. Must be non-null.

#### public GamesClient.Builder setGravityForPopups (int gravity)

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`.

##### Parameters

gravity | The gravity which controls the placement of games service popups.

##### Returns

- This Builder.

#### public GamesClient.Builder setScopes (String... scopes)

Set the scopes to use when building the GamesClient object.

The scope used by default is `GAMES`.

##### Parameters

scopes | The OAuth scopes that your application is requesting access to (see `Scopes` for details).

##### Returns

- This Builder.

#### public GamesClient.Builder setShowConnectingPopup (boolean showConnectingPopup)

Sets whether a "connecting" popup should be displayed automatically at the start of the sign-in flow. By default this is enabled.

Note that this call will use the default gravity for the "connecting" popup, which will display the popup at the center of the screen. If you prefer that the popup appear in a different section of the screen, you can use `setShowConnectingPopup(boolean, int)`, and provide a `Gravity` value.

##### Parameters

showConnectingPopup | Whether or not to show a "connecting" popup at the beginning of the sign-in flow. Default behavior is for this to be true.

##### Returns

- This Builder.

#### public GamesClient.Builder setShowConnectingPopup (boolean showConnectingPopup, int gravity)

Sets whether a "connecting" popup should be displayed automatically at the start of the sign-in flow. By default this is enabled.

##### Parameters

showConnectingPopup | Whether or not to show a "connecting" popup at the beginning of the sign-in flow. Default behavior is for this to be true.
gravity | The `Gravity` which controls where the "connecting" popup should be displayed during sign-in.

##### Returns

- This Builder.

#### public GamesClient.Builder setViewForPopups (View gamesContentView)

Sets the `View` to use as a content view for popups.

##### Parameters

gamesContentView | The view to use as a content view for popups. View cannot be null.

##### Returns

- This Builder.