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, get a GamesClient
by calling getGamesClient(Activity, GoogleSignInAccount)
or getGamesClient(Context, GoogleSignInAccount)
. Then request an
activation information by calling getActivationHint()
. If retrieved Bundle
is 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 |
This class is deprecated.
Use setViewForPopups(View) and setGravityForPopups(int) instead.
|
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | EXTRA_PLAYER_IDS | Used to return a list of player IDs. | |||||||||
String | EXTRA_STATUS | Used to return a Status object from activities. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns a new instance of
AchievementsClient for use in an Activity . | |||||||||||
Returns a new instance of
AchievementsClient for use in a Context . | |||||||||||
This method is deprecated.
Use
getAppId() instead.
| |||||||||||
This method is deprecated.
Use
getCurrentAccountName() instead.
| |||||||||||
Returns a new instance of
EventsClient for use in an Activity . | |||||||||||
Returns a new instance of
EventsClient for use in a Context . | |||||||||||
Returns a new instance of
GamesClient for use in an Activity . | |||||||||||
Returns a new instance of
GamesClient for use in a Context . | |||||||||||
Returns a new instance of
GamesMetadataClient for use in an Activity . | |||||||||||
Returns a new instance of
GamesMetadataClient for use in a Context . | |||||||||||
Returns a new instance of
InvitationsClient for use in a Context . | |||||||||||
Returns a new instance of
InvitationsClient for use in an Activity . | |||||||||||
Returns a new instance of
LeaderboardsClient for use in a Context . | |||||||||||
Returns a new instance of
LeaderboardsClient for use in an Activity . | |||||||||||
Returns a new instance of
NotificationsClient for use in a Context . | |||||||||||
Returns a new instance of
NotificationsClient for use in an Activity . | |||||||||||
Returns a new instance of
PlayerStatsClient for use in an Activity . | |||||||||||
Returns a new instance of
PlayerStatsClient for use in a Context . | |||||||||||
Returns a new instance of
PlayersClient for use in a Context . | |||||||||||
Returns a new instance of
PlayersClient for use in an Activity . | |||||||||||
Returns a new instance of
RealTimeMultiplayerClient for use in a Context . | |||||||||||
Returns a new instance of
RealTimeMultiplayerClient for use in an Activity . | |||||||||||
This method is deprecated.
Use
GamesClient#getSdkVariant() instead. | |||||||||||
This method is deprecated.
Use
getSettingsIntent() instead.
| |||||||||||
Returns a new instance of
SnapshotsClient for use in an Activity . | |||||||||||
Returns a new instance of
SnapshotsClient for use in a Context . | |||||||||||
Returns a new instance of
TurnBasedMultiplayerClient for use in a Context . | |||||||||||
Returns a new instance of
TurnBasedMultiplayerClient for use in an Activity . | |||||||||||
Returns a new instance of
VideosClient for use in a Context . | |||||||||||
Returns a new instance of
VideosClient for use in an Activity . | |||||||||||
This method is deprecated.
Use
setGravityForPopups(int) instead.
| |||||||||||
This method is deprecated.
Use
setViewForPopups(View) instead.
| |||||||||||
This method is deprecated.
Use
signOut()
instead.
|
[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)
.
See getSelectOpponentsIntent(int, int)
, getSelectOpponentsIntent(int, int)
Used to return a Status
object from activities. Retrieve with getParcelableExtra(String)
.
This field is deprecated.
This is no longer necessary to provide.
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>)
.
This field is deprecated.
Use getAchievementsClient(Activity, GoogleSignInAccount)
or getAchievementsClient(Context, GoogleSignInAccount)
instead.
Methods for interacting with achievements.
This field is deprecated.
Use getEventsClient(Activity, GoogleSignInAccount)
or getEventsClient(Context, GoogleSignInAccount)
instead.
Methods for interacting with events.
This field is deprecated.
Use getGamesMetadataClient(Activity, GoogleSignInAccount)
or getGamesMetadataClient(Context, GoogleSignInAccount)
instead.
Methods for interacting with game metadata.
This field is deprecated.
Use getInvitationsClient(Activity, GoogleSignInAccount)
or getInvitationsClient(Context, GoogleSignInAccount)
instead.
Methods for interacting with invitations.
This field is deprecated.
Use getLeaderboardsClient(Activity, GoogleSignInAccount)
or getLeaderboardsClient(Context, GoogleSignInAccount)
instead.
Methods for interacting with leaderboard data.
This field is deprecated.
Use getNotificationsClient(Activity, GoogleSignInAccount)
or getNotificationsClient(Context, GoogleSignInAccount)
instead.
Methods for interacting with notifications.
This field is deprecated.
Use getPlayersClient(Activity, GoogleSignInAccount)
or getPlayersClient(Context, GoogleSignInAccount)
instead.
Methods for interacting with players.
This field is deprecated.
The Google Play Games quests service will be deprecated as of March 2018. Do not
use the Google Play Games quests service in new apps. See the
deprecation announcement blog post for more details.
Methods for interacting with quests.
This field is deprecated.
Use getRealTimeMultiplayerClient(Activity, GoogleSignInAccount)
or getRealTimeMultiplayerClient(Context, GoogleSignInAccount)
instead.
Methods for interacting with real-time multiplayer games.
This field is deprecated.
The Google Play Games request service will be deprecated as of March 2018. Do not
use the Google Play Games request service in new apps. See the
deprecation announcement blog post for more details.
Methods for interacting with requests.
Scope for accessing data from Google Play Games without providing any user information.
This field is deprecated.
Use getSnapshotsClient(Activity, GoogleSignInAccount)
or getSnapshotsClient(Context, GoogleSignInAccount)
instead.
Methods for interacting with snapshots.
This field is deprecated.
Use getPlayerStatsClient(Activity, GoogleSignInAccount)
or getPlayerStatsClient(Context, GoogleSignInAccount)
instead.
Methods for interacting with game and player stats.
This field is deprecated.
Use getTurnBasedMultiplayerClient(Activity, GoogleSignInAccount)
or getTurnBasedMultiplayerClient(Context, GoogleSignInAccount)
instead.
Methods for interacting with turn-based multiplayer games.
This field is deprecated.
Use getVideosClient(Activity, GoogleSignInAccount)
or getVideosClient(Context, GoogleSignInAccount)
instead.
Methods for interacting with video recording.
Returns a new instance of AchievementsClient
for use in an Activity
.
Parameters | |
---|---|
activity |
Activity : The Activity for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
AchievementsClient |
Returns a new instance of AchievementsClient
for use in a Context
.
Parameters | |
---|---|
context |
Context : The Context for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
AchievementsClient |
This method is deprecated.
Use getAppId()
instead.
Get the application ID linked to this client instance.
Required API: API
Required Scopes: SCOPE_GAMES
Parameters | |
---|---|
apiClient |
GoogleApiClient : The GoogleApiClient to service the call. |
Returns | |
---|---|
String |
The application ID linked to this client instance. |
This method is deprecated.
Use getCurrentAccountName()
instead.
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
Parameters | |
---|---|
apiClient |
GoogleApiClient : The GoogleApiClient to service the call. |
Returns | |
---|---|
String |
Account name for the currently selected account. May be null if an error occurred while communicating with the games service. |
Throws | |
---|---|
SecurityException |
If your app doesn't have the GET_ACCOUNTS permission. |
Returns a new instance of EventsClient
for use in an Activity
.
Parameters | |
---|---|
activity |
Activity : The Activity for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
EventsClient |
Returns a new instance of EventsClient
for use in a Context
.
Parameters | |
---|---|
context |
Context : The Context for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
EventsClient |
Returns a new instance of GamesClient
for use in an Activity
.
Parameters | |
---|---|
activity |
Activity : The Activity for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
GamesClient |
Returns a new instance of GamesClient
for use in a Context
.
Parameters | |
---|---|
context |
Context : The Context for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
GamesClient |
Returns a new instance of GamesMetadataClient
for use in an Activity
.
Parameters | |
---|---|
activity |
Activity : The Activity for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
GamesMetadataClient |
Returns a new instance of GamesMetadataClient
for use in a Context
.
Parameters | |
---|---|
context |
Context : The Context for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
GamesMetadataClient |
Returns a new instance of InvitationsClient
for use in a Context
.
Parameters | |
---|---|
context |
Context : The Context for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
InvitationsClient |
Returns a new instance of InvitationsClient
for use in an Activity
.
Parameters | |
---|---|
activity |
Activity : The Activity for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
InvitationsClient |
Returns a new instance of LeaderboardsClient
for use in a Context
.
Parameters | |
---|---|
context |
Context : The Context for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
LeaderboardsClient |
Returns a new instance of LeaderboardsClient
for use in an Activity
.
Parameters | |
---|---|
activity |
Activity : The Activity for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
LeaderboardsClient |
Returns a new instance of NotificationsClient
for use in a Context
.
Parameters | |
---|---|
context |
Context : The Context for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
NotificationsClient |
Returns a new instance of NotificationsClient
for use in an Activity
.
Parameters | |
---|---|
activity |
Activity : The Activity for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
NotificationsClient |
Returns a new instance of PlayerStatsClient
for use in an Activity
.
Parameters | |
---|---|
activity |
Activity : The Activity for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
PlayerStatsClient |
Returns a new instance of PlayerStatsClient
for use in a Context
.
Parameters | |
---|---|
context |
Context : The Context for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
PlayerStatsClient |
Returns a new instance of PlayersClient
for use in a Context
.
Parameters | |
---|---|
context |
Context : The Context for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
PlayersClient |
Returns a new instance of PlayersClient
for use in an Activity
.
Parameters | |
---|---|
activity |
Activity : The Activity for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
PlayersClient |
Returns a new instance of RealTimeMultiplayerClient
for use in a Context
.
Parameters | |
---|---|
context |
Context : The Context for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
RealTimeMultiplayerClient |
Returns a new instance of RealTimeMultiplayerClient
for use in an Activity
.
Parameters | |
---|---|
activity |
Activity : The Activity for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
RealTimeMultiplayerClient |
This method is deprecated.
Use GamesClient#getSdkVariant()
instead.
Parameters | |
---|---|
apiClient |
GoogleApiClient |
Returns | |
---|---|
int |
This method is deprecated.
Use getSettingsIntent()
instead.
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
Parameters | |
---|---|
apiClient |
GoogleApiClient : The GoogleApiClient to service the call. |
Returns | |
---|---|
Intent |
An Intent that can be started to view the GoogleApiClient Settings UI. |
Returns a new instance of SnapshotsClient
for use in an Activity
.
Parameters | |
---|---|
activity |
Activity : The Activity for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
SnapshotsClient |
Returns a new instance of SnapshotsClient
for use in a Context
.
Parameters | |
---|---|
context |
Context : The Context for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
SnapshotsClient |
Returns a new instance of TurnBasedMultiplayerClient
for use in a Context
.
Parameters | |
---|---|
context |
Context : The Context for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
TurnBasedMultiplayerClient |
Returns a new instance of TurnBasedMultiplayerClient
for use in an Activity
.
Parameters | |
---|---|
activity |
Activity : The Activity for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
TurnBasedMultiplayerClient |
Returns a new instance of VideosClient
for use in a Context
.
Parameters | |
---|---|
context |
Context : The Context for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
VideosClient |
Returns a new instance of VideosClient
for use in an Activity
.
Parameters | |
---|---|
activity |
Activity : The Activity for this client. |
account |
GoogleSignInAccount : The GoogleSignInAccount to authorize API calls.
|
Returns | |
---|---|
VideosClient |
This method is deprecated.
Use setGravityForPopups(int)
instead.
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
Parameters | |
---|---|
apiClient |
GoogleApiClient : The GoogleApiClient to service the call. |
gravity |
int : The gravity which controls the placement of games service popups. |
This method is deprecated.
Use setViewForPopups(View)
instead.
Sets the View
to use as a content view for popups.
Required API: API
Required Scopes: SCOPE_GAMES
Parameters | |
---|---|
apiClient |
GoogleApiClient : The GoogleApiClient to service the call. |
gamesContentView |
View : The view to use as a content view for popups. View cannot be null. |
This method is deprecated.
Use signOut()
instead.
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
Parameters | |
---|---|
apiClient |
GoogleApiClient : The GoogleApiClient to service the call. |
Returns | |
---|---|
PendingResult<Status> |
PendingResult to access the data when available. |