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
GamesClient.getActivationHint()
. If retrieved Bundle
is not null it
can contain the following keys:
Snapshots.EXTRA_SNAPSHOT_METADATA
if the user wanted to resume a saved game. The value contained here is aSnapshotMetadata
object which can be accessed withBundle.getParcelable(String)
.
For more information, visit the getting started guide.
Nested Class Summary
class | Games.GamesOptions | API configuration parameters for Games. |
Constant Summary
String | EXTRA_PLAYER_IDS | Used to return a list of player IDs. |
String | EXTRA_STATUS | Used to return a Status
object from activities. |
Field Summary
Public Method Summary
Inherited Method Summary
Constants
public static final String EXTRA_PLAYER_IDS
Used to return a list of player IDs. Retrieve with
Intent.getStringArrayListExtra(String)
.
Also used to pass in a list of player IDs for preselecting players. Set with
Intent.putStringArrayListExtra(String, java.util.ArrayList)
.
public static final String EXTRA_STATUS
Used to return a Status
object from activities. Retrieve with
Intent.getParcelableExtra(String)
.
Fields
public static final Api<Games.GamesOptions> API
This field is deprecated.
This is no longer necessary to provide.
Token to pass to
GoogleApiClient.Builder.addApi(Api extends Api.ApiOptions.NotRequiredOptions>
)
to enable the Games features.
To configure additional Games options, provide a Games.GamesOptions
object to
GoogleApiClient.Builder.addApi(Api extends Api.ApiOptions.NotRequiredOptions>
)
.
public static final Achievements Achievements
This field is deprecated.
Use
getAchievementsClient(Activity, GoogleSignInAccount)
or
getAchievementsClient(Context, GoogleSignInAccount)
instead.
Methods for interacting with achievements.
public static final Events Events
This field is deprecated.
Use
getEventsClient(Activity, GoogleSignInAccount)
or
getEventsClient(Context, GoogleSignInAccount)
instead.
Methods for interacting with events.
public static final GamesMetadata GamesMetadata
This field is deprecated.
Use
getGamesMetadataClient(Activity, GoogleSignInAccount)
or
getGamesMetadataClient(Context, GoogleSignInAccount)
instead.
Methods for interacting with game metadata.
public static final Leaderboards Leaderboards
This field is deprecated.
Use
getLeaderboardsClient(Activity, GoogleSignInAccount)
or
getLeaderboardsClient(Context, GoogleSignInAccount)
instead.
Methods for interacting with leaderboard data.
public static final Players Players
This field is deprecated.
Use
getPlayersClient(Activity, GoogleSignInAccount)
or
getPlayersClient(Context, GoogleSignInAccount)
instead.
Methods for interacting with players.
public static final Scope SCOPE_GAMES
Scope for accessing data from Google Play Games.
public static final Scope SCOPE_GAMES_LITE
Scope for accessing data from Google Play Games without providing any user information.
public static final Scope SCOPE_GAMES_SNAPSHOTS
Scope for accessing SnapshotsClient
API.
public static final Snapshots Snapshots
This field is deprecated.
Use
getSnapshotsClient(Activity, GoogleSignInAccount)
or
getSnapshotsClient(Context, GoogleSignInAccount)
instead.
Methods for interacting with snapshots.
public static final Stats Stats
This field is deprecated.
Use
getPlayerStatsClient(Activity, GoogleSignInAccount)
or
getPlayerStatsClient(Context, GoogleSignInAccount)
instead.
Methods for interacting with game and player stats.
public static final Videos Videos
This field is deprecated.
Use
getVideosClient(Activity, GoogleSignInAccount)
or
getVideosClient(Context, GoogleSignInAccount)
instead.
Methods for interacting with video recording.
Public Methods
public static AchievementsClient getAchievementsClient (Activity activity, GoogleSignInAccount account)
Returns a new instance of AchievementsClient
for use in an Activity
.
Required Scopes for use: SCOPE_GAMES_LITE
Parameters
activity | The Activity
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
public static AchievementsClient getAchievementsClient (Context context, GoogleSignInAccount account)
Returns a new instance of AchievementsClient
for use in a Context
.
Required Scopes for use: SCOPE_GAMES_LITE
Parameters
context | The Context
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
public static AchievementsClient getAchievementsClient (Context context, GoogleSignInAccount account, Games.GamesOptions options)
Returns a new instance of AchievementsClient
for use in a Context
.
Required Scopes for use: SCOPE_GAMES_LITE
Parameters
context | The Context
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
options | The Games.GamesOptions
for this client. |
public static AchievementsClient getAchievementsClient (Activity activity, GoogleSignInAccount account, Games.GamesOptions options)
Returns a new instance of AchievementsClient
for use in an Activity
.
Required Scopes for use: SCOPE_GAMES_LITE
Parameters
activity | The Activity
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
options | The Games.GamesOptions
for this client. |
public static String getCurrentAccountName (GoogleApiClient apiClient)
This method is deprecated.
Use
GamesClient.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 | The GoogleApiClient
to service the call. |
---|
Returns
- 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 Manifest.permission.GET_ACCOUNTS
permission. |
---|
public static EventsClient getEventsClient (Context context, GoogleSignInAccount account, Games.GamesOptions options)
Returns a new instance of EventsClient
for use in a Context
.
Required Scopes for use: SCOPE_GAMES_LITE
Parameters
context | The Context
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
options | The Games.GamesOptions
for this client. |
public static EventsClient getEventsClient (Activity activity, GoogleSignInAccount account, Games.GamesOptions options)
Returns a new instance of EventsClient
for use in an Activity
.
Required Scopes for use: SCOPE_GAMES_LITE
Parameters
activity | The Activity
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
options | The Games.GamesOptions
for this client. |
public static EventsClient getEventsClient (Activity activity, GoogleSignInAccount account)
Returns a new instance of EventsClient
for use in an Activity
.
Required Scopes for use: SCOPE_GAMES_LITE
Parameters
activity | The Activity
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
public static EventsClient getEventsClient (Context context, GoogleSignInAccount account)
Returns a new instance of EventsClient
for use in a Context
.
Required Scopes for use: SCOPE_GAMES_LITE
Parameters
context | The Context
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
public static GamesClient getGamesClient (Activity activity, GoogleSignInAccount account)
Returns a new instance of GamesClient
for use in an Activity
.
Required Scopes: SCOPE_GAMES_LITE
Parameters
activity | The Activity
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
public static GamesClient getGamesClient (Activity activity, GoogleSignInAccount account, Games.GamesOptions options)
Returns a new instance of GamesClient
for use in an Activity
.
Required Scopes for use: SCOPE_GAMES_LITE
Parameters
activity | The Activity
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
options | The Games.GamesOptions
for this client. |
public static GamesClient getGamesClient (Context context, GoogleSignInAccount account)
Returns a new instance of GamesClient
for use in a Context
.
Required Scopes for use: SCOPE_GAMES_LITE
Parameters
context | The Context
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
public static GamesClient getGamesClient (Context context, GoogleSignInAccount account, Games.GamesOptions options)
Returns a new instance of GamesClient
for use in a Context
.
Required Scopes: SCOPE_GAMES_LITE
Parameters
context | The Context
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
options | The Games.GamesOptions
for this client. |
public static GamesMetadataClient getGamesMetadataClient (Context context, GoogleSignInAccount account, Games.GamesOptions options)
Returns a new instance of GamesMetadataClient
for use in a Context
.
Required Scopes: SCOPE_GAMES_LITE
Parameters
context | The Context
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
options | The Games.GamesOptions
for this client. |
public static GamesMetadataClient getGamesMetadataClient (Activity activity, GoogleSignInAccount account, Games.GamesOptions options)
Returns a new instance of GamesMetadataClient
for use in an Activity
.
Required Scopes: SCOPE_GAMES_LITE
Parameters
activity | The Activity
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
options | The Games.GamesOptions
for this client. |
public static GamesMetadataClient getGamesMetadataClient (Activity activity, GoogleSignInAccount account)
Returns a new instance of GamesMetadataClient
for use in an Activity
.
Required Scopes: SCOPE_GAMES_LITE
Parameters
activity | The Activity
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
public static GamesMetadataClient getGamesMetadataClient (Context context, GoogleSignInAccount account)
Returns a new instance of GamesMetadataClient
for use in a Context
.
Required Scopes: SCOPE_GAMES_LITE
Parameters
context | The Context
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
public static LeaderboardsClient getLeaderboardsClient (Context context, GoogleSignInAccount account)
Returns a new instance of LeaderboardsClient
for use in a Context
.
Required Scopes: SCOPE_GAMES_LITE
Parameters
context | The Context
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
public static LeaderboardsClient getLeaderboardsClient (Activity activity, GoogleSignInAccount account)
Returns a new instance of LeaderboardsClient
for use in an Activity
.
Required Scopes: SCOPE_GAMES_LITE
Parameters
activity | The Activity
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
public static LeaderboardsClient getLeaderboardsClient (Context context, GoogleSignInAccount account, Games.GamesOptions options)
Returns a new instance of LeaderboardsClient
for use in a Context
.
Required Scopes: SCOPE_GAMES_LITE
Parameters
context | The Context
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
options | The Games.GamesOptions
for this client. |
public static LeaderboardsClient getLeaderboardsClient (Activity activity, GoogleSignInAccount account, Games.GamesOptions options)
Returns a new instance of LeaderboardsClient
for use in an Activity
.
Required Scopes: SCOPE_GAMES_LITE
Parameters
activity | The Activity
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
options | The Games.GamesOptions
for this client. |
public static PlayerStatsClient getPlayerStatsClient (Context context, GoogleSignInAccount account, Games.GamesOptions options)
Returns a new instance of PlayerStatsClient
for use in a Context
.
Required Scopes: SCOPE_GAMES_LITE
Parameters
context | The Context
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
options | The Games.GamesOptions
for this client. |
public static PlayerStatsClient getPlayerStatsClient (Activity activity, GoogleSignInAccount account, Games.GamesOptions options)
Returns a new instance of PlayerStatsClient
for use in an Activity
.
Required Scopes: SCOPE_GAMES_LITE
Parameters
activity | The Activity
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
options | The Games.GamesOptions
for this client. |
public static PlayerStatsClient getPlayerStatsClient (Activity activity, GoogleSignInAccount account)
Returns a new instance of PlayerStatsClient
for use in an Activity
.
Required Scopes: SCOPE_GAMES_LITE
Parameters
activity | The Activity
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
public static PlayerStatsClient getPlayerStatsClient (Context context, GoogleSignInAccount account)
Returns a new instance of PlayerStatsClient
for use in a Context
.
Required Scopes: SCOPE_GAMES_LITE
Parameters
context | The Context
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
public static PlayersClient getPlayersClient (Activity activity, GoogleSignInAccount account, Games.GamesOptions options)
Returns a new instance of PlayersClient
for use in an Activity
.
Required Scopes: SCOPE_GAMES_LITE
Parameters
activity | The Activity
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
options | The Games.GamesOptions
for this client. |
public static PlayersClient getPlayersClient (Context context, GoogleSignInAccount account)
Returns a new instance of PlayersClient
for use in a Context
.
Required Scopes: SCOPE_GAMES_LITE
Parameters
context | The Context
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
public static PlayersClient getPlayersClient (Activity activity, GoogleSignInAccount account)
Returns a new instance of PlayersClient
for use in an Activity
.
Required Scopes: SCOPE_GAMES_LITE
Parameters
activity | The Activity
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
public static PlayersClient getPlayersClient (Context context, GoogleSignInAccount account, Games.GamesOptions options)
Returns a new instance of PlayersClient
for use in a Context
.
Required Scopes: SCOPE_GAMES_LITE
Parameters
context | The Context
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
options | The Games.GamesOptions
for this client. |
public static SnapshotsClient getSnapshotsClient (Context context, GoogleSignInAccount account, Games.GamesOptions options)
Returns a new instance of SnapshotsClient
for use in a Context
.
Required Scopes: SCOPE_GAMES_LITE
and
SCOPE_GAMES_SNAPSHOTS
.
Parameters
context | The Context
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
options | The Games.GamesOptions
for this client. |
public static SnapshotsClient getSnapshotsClient (Activity activity, GoogleSignInAccount account)
Returns a new instance of SnapshotsClient
for use in an Activity
.
Required Scopes: SCOPE_GAMES_LITE
and
SCOPE_GAMES_SNAPSHOTS
.
Parameters
activity | The Activity
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
public static SnapshotsClient getSnapshotsClient (Context context, GoogleSignInAccount account)
Returns a new instance of SnapshotsClient
for use in a Context
.
Required Scopes: SCOPE_GAMES_LITE
and
SCOPE_GAMES_SNAPSHOTS
.
Parameters
context | The Context
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
public static SnapshotsClient getSnapshotsClient (Activity activity, GoogleSignInAccount account, Games.GamesOptions options)
Returns a new instance of SnapshotsClient
for use in an Activity
.
Required Scopes: SCOPE_GAMES_LITE
and
SCOPE_GAMES_SNAPSHOTS
.
Parameters
activity | The Activity
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
options | The Games.GamesOptions
for this client. |
public static VideosClient getVideosClient (Context context, GoogleSignInAccount account, Games.GamesOptions options)
This method is deprecated.
Video recording using Play Games Services will be disabled for Android SDK levels greater
than 32.
Returns a new instance of VideosClient
for use in a Context
.
Required Scopes: SCOPE_GAMES_LITE
Parameters
context | The Context
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
options | The Games.GamesOptions
for this client. |
public static VideosClient getVideosClient (Activity activity, GoogleSignInAccount account, Games.GamesOptions options)
This method is deprecated.
Video recording using Play Games Services will be disabled for Android SDK levels greater
than 32.
Returns a new instance of VideosClient
for use in an Activity
.
Required Scopes: SCOPE_GAMES_LITE
Parameters
activity | The Activity
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
options | The Games.GamesOptions
for this client. |
public static VideosClient getVideosClient (Context context, GoogleSignInAccount account)
This method is deprecated.
Video recording using Play Games Services will be disabled for Android SDK levels greater
than 32.
Returns a new instance of VideosClient
for use in a Context
.
Required Scopes: SCOPE_GAMES_LITE
Parameters
context | The Context
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
public static VideosClient getVideosClient (Activity activity, GoogleSignInAccount account)
This method is deprecated.
Video recording using Play Games Services will be disabled for Android SDK levels greater
than 32.
Required Scopes: SCOPE_GAMES_LITE
Returns a new instance of VideosClient
for use in an Activity
.
Parameters
activity | The Activity
for this client. |
---|---|
account | The
GoogleSignInAccount to authorize API calls. |
public static PendingResult<Status> signOut (GoogleApiClient apiClient)
This method is deprecated.
Use
GoogleSignInClient.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 | The GoogleApiClient
to service the call. |
---|
Returns
PendingResult
to access the data when available.