java.lang.Object | |
↳ | com.google.android.gms.games.Games |
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 API
to
addApi(Api extends Api.ApiOptions.NotRequiredOptions>)
. Once you have your GoogleApiClient
, call
connect()
and wait for the
onConnected(Bundle)
method to be called. The Bundle provided
to onConnected
may be null. If not null, it can contain the following keys:
EXTRA_INVITATION
if the user wanted to accept an invitation to a
multiplayer game. The value contained here is an Invitation
which can be accessed with
getParcelable(String)
.EXTRA_TURN_BASED_MATCH
if the user wanted to take action in a turn-based
match. The value contained here is a TurnBasedMatch
which can be accessed with
getParcelable(String)
.EXTRA_REQUESTS
if the user wanted to accept one or more requests. The value
contained here is a list of GameRequest
objects which can be accessed with
getParcelableArrayList(String)
.
EXTRA_SNAPSHOT_METADATA
if the user wanted to resume a saved game. The
value contained here is a SnapshotMetadata
object which can be accessed with
getParcelable(String)
.
EXTRA_QUEST
if the user wanted to accept a specific quest. The value contained
here is a Quest
which can be accessed with getParcelable(String)
.
For more information, see the "Getting Started" guide available at https://developers.google.com/games/services/android/quickstart.
Nested Classes | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Games.GamesOptions | API configuration parameters for Games. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | EXTRA_PLAYER_IDS | Used to return a list of player IDs. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
API |
Token to pass to addApi(Api extends Api.ApiOptions.NotRequiredOptions>) to enable the Games features.
|
||||||||||
Achievements | Methods for interacting with achievements. | ||||||||||
Events | Methods for interacting with events. | ||||||||||
GamesMetadata | Methods for interacting with game metadata. | ||||||||||
Invitations | Methods for interacting with invitations. | ||||||||||
Leaderboards | Methods for interacting with leaderboard data. | ||||||||||
Notifications | Methods for interacting with notifications. | ||||||||||
Players | Methods for interacting with players. | ||||||||||
Quests | Methods for interacting with quests. | ||||||||||
RealTimeMultiplayer | Methods for interacting with real-time multiplayer games. | ||||||||||
Requests | Methods for interacting with requests. | ||||||||||
SCOPE_GAMES | Scope for accessing data from Google Play Games. | ||||||||||
Snapshots | Methods for interacting with snapshots. | ||||||||||
TurnBasedMultiplayer | Methods for interacting with turn-based multiplayer games. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Get the application ID linked to this client instance.
| |||||||||||
Get the name of the currently selected account.
| |||||||||||
Gets an intent to show the Settings screen that allows the user to configure Games-related
features for the current game.
| |||||||||||
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 the
View to use as a content view for popups.
| |||||||||||
Asynchronously signs the current user out.
|
[Expand]
Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Used to return a list of player IDs. Retrieve with
getStringArrayListExtra(String)
.
Also used to pass in a list of player IDs for preselecting players. Set with
putStringArrayListExtra(String, java.util.ArrayList)
.
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>)
.
Methods for interacting with real-time multiplayer games.
Methods for interacting with turn-based multiplayer games.
Get the application ID linked to this client instance.
Required API: API
Required Scopes: SCOPE_GAMES
apiClient | The GoogleApiClient to service the call. |
---|
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
have <uses-permission android:name="android.permission.GET_ACCOUNTS" />
declared in your manifest in order to use this method.
Required API: API
Required Scopes: SCOPE_GAMES
apiClient | The GoogleApiClient to service the call. |
---|
SecurityException | If your app doesn't have the
GET_ACCOUNTS permission.
|
---|
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.
A RESULT_RECONNECT_REQUIRED
may be returned as the
resultCode in onActivityResult(int, int, Intent)
if the GoogleApiClient ends up in an
inconsistent state.
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.
Required API: API
Required Scopes: SCOPE_GAMES
apiClient | The GoogleApiClient to service the call. |
---|
Intent
that can be started to view the GoogleApiClient Settings UI.
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
.
Required API: API
Required Scopes: SCOPE_GAMES
apiClient | The GoogleApiClient to service the call. |
---|---|
gravity | The gravity which controls the placement of games service popups. |
Sets the View
to use as a content view for popups.
Required API: API
Required Scopes: SCOPE_GAMES
apiClient | The GoogleApiClient to service the call. |
---|---|
gamesContentView | The view to use as a content view for popups. View cannot be null. |
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.
Required API: API
Required Scopes: SCOPE_GAMES
apiClient | The GoogleApiClient to service the call. |
---|
PendingResult
to access the data when available.