Main entry point for the Games APIs. This class provides APIs and interfaces to access the Google Play game services functionality.
To use the service, construct a
GoogleApiClient and pass
addApi(Api extends Api.ApiOptions.NotRequiredOptions>). Once you have your
connect() and wait for the
onConnected(Bundle) method to be called. The Bundle provided
onConnected may be null. If not null, it can contain the following keys:
EXTRA_INVITATIONif the user wanted to accept an invitation to a multiplayer game. The value contained here is an
Invitationwhich can be accessed with
EXTRA_TURN_BASED_MATCHif the user wanted to take action in a turn-based match. The value contained here is a
TurnBasedMatchwhich can be accessed with
EXTRA_REQUESTSif the user wanted to accept one or more requests. The value contained here is a list of
GameRequestobjects which can be accessed with
EXTRA_SNAPSHOT_METADATAif the user wanted to resume a saved game. The value contained here is a
SnapshotMetadataobject which can be accessed with
EXTRA_QUESTif the user wanted to accept a specific quest. The value contained here is a
Questwhich can be accessed with
For more information, see the "Getting Started" guide available at https://developers.google.com/games/services/android/quickstart.
Nested Class Summary
|class||Games.GamesOptions||API configuration parameters for Games.|
|interface||Games.GetTokenResult||Result delivered when the auth token has been retrieved.|
|String||EXTRA_PLAYER_IDS||Used to return a list of player IDs.|
|String||EXTRA_STATUS||Used to return a
|public static final Api<Games.GamesOptions>||API||Token to pass to
|public static final Achievements||Achievements||Methods for interacting with achievements.|
|public static final Events||Events||Methods for interacting with events.|
|public static final GamesMetadata||GamesMetadata||Methods for interacting with game metadata.|
|public static final Invitations||Invitations||Methods for interacting with invitations.|
|public static final Leaderboards||Leaderboards||Methods for interacting with leaderboard data.|
|public static final Notifications||Notifications||Methods for interacting with notifications.|
|public static final Players||Players||Methods for interacting with players.|
|public static final Quests||Quests||Methods for interacting with quests.|
|public static final RealTimeMultiplayer||RealTimeMultiplayer||Methods for interacting with real-time multiplayer games.|
|public static final Requests||Requests||Methods for interacting with requests.|
|public static final Scope||SCOPE_GAMES||Scope for accessing data from Google Play Games.|
|public static final Snapshots||Snapshots||Methods for interacting with snapshots.|
|public static final Stats||Stats||Methods for interacting with game and player stats.|
|public static final TurnBasedMultiplayer||TurnBasedMultiplayer||Methods for interacting with turn-based multiplayer games.|
Public Method Summary
public static final String EXTRA_PLAYER_IDS
Used to return a list of player IDs. Retrieve with
Also used to pass in a list of player IDs for preselecting players. Set with
public static final Api<Games.GamesOptions> API
Token to pass to
addApi(Api extends Api.ApiOptions.NotRequiredOptions>) to enable the Games features.
To configure additional Games options, provide a
Games.GamesOptions object to
addApi(Api extends Api.ApiOptions.NotRequiredOptions>).
public static final Achievements Achievements
Methods for interacting with achievements.
public static final Events Events
Methods for interacting with events.
public static final GamesMetadata GamesMetadata
Methods for interacting with game metadata.
public static final Invitations Invitations
Methods for interacting with invitations.
public static final Leaderboards Leaderboards
Methods for interacting with leaderboard data.
public static final Notifications Notifications
Methods for interacting with notifications.
public static final Players Players
Methods for interacting with players.
public static final Quests Quests
Methods for interacting with quests.
public static final RealTimeMultiplayer RealTimeMultiplayer
Methods for interacting with real-time multiplayer games.
public static final Requests Requests
Methods for interacting with requests.
public static final Scope SCOPE_GAMES
Scope for accessing data from Google Play Games.
public static final Snapshots Snapshots
Methods for interacting with snapshots.
public static final Stats Stats
Methods for interacting with game and player stats.
public static final TurnBasedMultiplayer TurnBasedMultiplayer
Methods for interacting with turn-based multiplayer games.
public static String getAppId (GoogleApiClient apiClient)
public static String getCurrentAccountName (GoogleApiClient apiClient)
Get the name of the currently selected account. This is the account the user has chosen to use for Google Play Games.
Note that the
GoogleApiClient must be connected to call this API, and your app must
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
declared in your manifest in order to use this method.
- Account name for the currently selected account. May be null if an error occurred while communicating with the games service.
public static PendingResult<Games.GetTokenResult> getGamesAuthToken (GoogleApiClient apiClient)
public static int getSdkVariant (GoogleApiClient apiClient)
public static Intent getSettingsIntent (GoogleApiClient apiClient)
Gets an intent to show the Settings screen that allows the user to configure Games-related
features for the current game. Note that this must be invoked with
startActivityForResult(Intent, int), so that the identity of the calling
package can be established.
Most applications will not need to call this directly, since the Settings UI is already reachable from most other Games UI screens (achievements, leaderboards, etc.) via a menu item.
Intentthat can be started to view the GoogleApiClient Settings UI.
public static void setGravityForPopups (GoogleApiClient apiClient, 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.
|gravity||The gravity which controls the placement of games service popups.|
public static void setViewForPopups (GoogleApiClient apiClient, View gamesContentView)
public static PendingResult<Status> signOut (GoogleApiClient apiClient)
Asynchronously signs the current user out.
This call doesn't disconnect the Google API Client. As no user is signed in after this call is completed, subsequent calls to this client will very likely fail. You should either call disconnect() or finish your Activity after this call.
PendingResultto access the data when available.