public interface

Players

com.google.android.gms.games.Players

Class Overview

Entry point for player functionality.

Summary

Nested Classes
interface Players.LoadPlayersResult Result delivered when player data has been loaded. 
interface Players.LoadProfileSettingsResult Result delivered when the profile settings of the signed-in player have been loaded. 
Constants
String EXTRA_PLAYER_SEARCH_RESULTS Used by the Player Search UI to return a list of parceled Player objects.
Public Methods
abstract Player getCurrentPlayer(GoogleApiClient apiClient)
Get the current signed in player, if available.
abstract String getCurrentPlayerId(GoogleApiClient apiClient)
Get the current signed in player ID, if available.
abstract Intent getPlayerSearchIntent(GoogleApiClient apiClient)
Returns an intent that will display a screen where the user can search for people on Google+.
abstract PendingResult<Players.LoadPlayersResult> loadConnectedPlayers(GoogleApiClient apiClient, boolean forceReload)
Asynchronously loads a list of players that have connected to this game (and that the user has permission to know about).
abstract PendingResult<Players.LoadPlayersResult> loadInvitablePlayers(GoogleApiClient apiClient, int pageSize, boolean forceReload)
Load the initial page of players the currently signed-in player can invite to a multiplayer game, sorted alphabetically by name.
abstract PendingResult<Players.LoadPlayersResult> loadMoreInvitablePlayers(GoogleApiClient apiClient, int pageSize)
Asynchronously loads an additional page of invitable players.
abstract PendingResult<Players.LoadPlayersResult> loadMoreRecentlyPlayedWithPlayers(GoogleApiClient apiClient, int pageSize)
Asynchronously loads an additional page of players that the signed-in player has played multiplayer games with recently.
abstract PendingResult<Players.LoadPlayersResult> loadPlayer(GoogleApiClient apiClient, String playerId)
Loads the profile for the requested player ID.
abstract PendingResult<Players.LoadPlayersResult> loadRecentlyPlayedWithPlayers(GoogleApiClient apiClient, int pageSize, boolean forceReload)
Load the initial page of players the currently signed-in player has played multiplayer games with recently, starting with the most recent.

Constants

public static final String EXTRA_PLAYER_SEARCH_RESULTS

Used by the Player Search UI to return a list of parceled Player objects. Retrieve with getParcelableArrayListExtra(String).

Constant Value: "player_search_results"

Public Methods

public abstract Player getCurrentPlayer (GoogleApiClient apiClient)

Get the current signed in player, if available.

Required API: API
Required Scopes: SCOPE_GAMES

Parameters
apiClient The GoogleApiClient to service the call.
Returns
  • Player representing the currently signed in player. May be null if an error occurred while communicating with the games service.

public abstract String getCurrentPlayerId (GoogleApiClient apiClient)

Get the current signed in player ID, if available.

Required API: API
Required Scopes: SCOPE_GAMES

Parameters
apiClient The GoogleApiClient to service the call.
Returns
  • The player ID for the currently signed in player. May be null if an error occurred while communicating with the games service.

public abstract Intent getPlayerSearchIntent (GoogleApiClient apiClient)

Returns an intent that will display a screen where the user can search for people on Google+. Note that this must be invoked with startActivityForResult(Intent, int), so that the identity of the calling package can be established.

If the user canceled, the result will be RESULT_CANCELED. If the user selected any players from the search results list, the result will be RESULT_OK, and the data intent will contain a list of parceled Player objects in EXTRA_PLAYER_SEARCH_RESULTS.

Note that the current Player Search UI only allows a single selection, so the returned list of parceled Player objects will currently contain at most one Player. The Player Search UI may allow multiple selections in a future release, though.

Required API: API
Required Scopes: SCOPE_GAMES

Parameters
apiClient The GoogleApiClient to service the call.
Returns
  • An Intent that can be started to display the player selector.

public abstract PendingResult<Players.LoadPlayersResult> loadConnectedPlayers (GoogleApiClient apiClient, boolean forceReload)

Asynchronously loads a list of players that have connected to this game (and that the user has permission to know about).

Required API: API
Required Scopes: SCOPE_GAMES

Parameters
apiClient The GoogleApiClient to service the call.
forceReload If true, this call will clear any locally cached data and attempt to fetch the latest data from the server. This would commonly be used for something like a user-initiated refresh. Normally, this should be set to false to gain advantages of data caching.

public abstract PendingResult<Players.LoadPlayersResult> loadInvitablePlayers (GoogleApiClient apiClient, int pageSize, boolean forceReload)

Load the initial page of players the currently signed-in player can invite to a multiplayer game, sorted alphabetically by name.

Required API: API
Required Scopes: SCOPE_GAMES

Parameters
apiClient The GoogleApiClient to service the call.
pageSize The number of entries to request for this initial page. Note that if cached data already exists, the returned buffer may contain more than this size, but it is guaranteed to contain at least this many if the collection contains enough records. This must be a value between 1 and 25.
forceReload If true, this call will clear any locally cached data and attempt to fetch the latest data from the server. This would commonly be used for something like a user-initiated refresh. Normally, this should be set to false to gain advantages of data caching.
Returns

public abstract PendingResult<Players.LoadPlayersResult> loadMoreInvitablePlayers (GoogleApiClient apiClient, int pageSize)

Asynchronously loads an additional page of invitable players. A new player buffer will be delivered that includes an extra page of results.

Required API: API
Required Scopes: SCOPE_GAMES

Parameters
apiClient The GoogleApiClient to service the call.
pageSize The number of additional entries to request. This must be a value between 1 and 25.
Returns

public abstract PendingResult<Players.LoadPlayersResult> loadMoreRecentlyPlayedWithPlayers (GoogleApiClient apiClient, int pageSize)

Asynchronously loads an additional page of players that the signed-in player has played multiplayer games with recently. A new player buffer will be delivered that includes an extra page of results.

Required API: API
Required Scopes: SCOPE_GAMES

Parameters
apiClient The GoogleApiClient to service the call.
pageSize The number of additional entries to request. This must be a value between 1 and 25.
Returns

public abstract PendingResult<Players.LoadPlayersResult> loadPlayer (GoogleApiClient apiClient, String playerId)

Loads the profile for the requested player ID.

Required API: API
Required Scopes: SCOPE_GAMES

Parameters
apiClient The GoogleApiClient to service the call.
playerId The player ID to get full profile data for.
Returns

public abstract PendingResult<Players.LoadPlayersResult> loadRecentlyPlayedWithPlayers (GoogleApiClient apiClient, int pageSize, boolean forceReload)

Load the initial page of players the currently signed-in player has played multiplayer games with recently, starting with the most recent.

Required API: API
Required Scopes: SCOPE_GAMES

Parameters
apiClient The GoogleApiClient to service the call.
pageSize The number of entries to request for this initial page. Note that if cached data already exists, the returned buffer may contain more than this size, but it is guaranteed to contain at least this many if the collection contains enough records. This must be a value between 1 and 25.
forceReload If true, this call will clear any locally cached data and attempt to fetch the latest data from the server. This would commonly be used for something like a user-initiated refresh. Normally, this should be set to false to gain advantages of data caching.
Returns