A client to interact with Players.
Constant Summary
String | EXTRA_PLAYER_SEARCH_RESULTS | Used by the Player Search UI to return a list of parceled Player objects. |
Public Method Summary
abstractTask<Intent> |
getCompareProfileIntent(String
otherPlayerId)
|
abstractTask<Intent> |
getCompareProfileIntent(Player
player)
|
abstractTask<Intent> | |
abstractTask<AnnotatedData<Player>> |
getCurrentPlayer(boolean forceReload)
|
abstractTask<Player> | |
abstractTask<String> |
getCurrentPlayerId()
Returns a
Task
which asynchronously loads the current signed-in player ID, if available.
|
abstractTask<Intent> | |
abstractTask<AnnotatedData<PlayerBuffer>> |
loadFriends(int pageSize, boolean forceReload)
Returns a
Task
which asynchronously loads an annotatedPlayerBuffer
that represents friends the user has.
|
abstractTask<AnnotatedData<PlayerBuffer>> |
loadMoreFriends(int pageSize)
Returns a
Task
which asynchronously loads an annotatedPlayerBuffer
that represents friends the user has.
|
abstractTask<AnnotatedData<PlayerBuffer>> |
loadMoreRecentlyPlayedWithPlayers(int pageSize)
This method is deprecated. Real-time multiplayer and Turn-based multiplayer
support is being shut down on March 31, 2020. SeeMultiplayer
deprecation
|
abstractTask<AnnotatedData<Player>> |
loadPlayer(StringplayerId,
boolean forceReload)
|
abstractTask<AnnotatedData<Player>> |
loadPlayer(StringplayerId)
|
abstractTask<AnnotatedData<PlayerBuffer>> |
loadRecentlyPlayedWithPlayers(int pageSize, boolean forceReload)
This method is deprecated. Real-time multiplayer and Turn-based multiplayer
support is being shut down on March 31, 2020. SeeMultiplayer
deprecation
|
Constants
public static finalString EXTRA_PLAYER_SEARCH_RESULTS
Used by the Player Search UI to return a list of parceled Player objects. Retrieve
with
Intent.getParcelableArrayListExtra(String)
.
Public Methods
public abstractTask<Intent> getCompareProfileIntent(String otherPlayerId)
Returns aTask
which
asynchronously loads anIntent
that
will display a screen where the user can see a comparison of their own profile against
another player's profile. Note that theIntent
returned from the
Task
must be invoked with
Activity.startActivityForResult(Intent, int)
,so that the identity of the
calling package can be established.
Parameters
otherPlayerId | The player ID of the player to compare with. |
---|
public abstractTask<Intent> getCompareProfileIntent(Player player)
Returns aTask
which
asynchronously loads anIntent
that
will display a screen where the user can compare themselves against another player's
profile. Note that theIntent
returned from theTask
must be
invoked with
Activity.startActivityForResult(Intent, int)
,so that the identity of the
calling package can be established.
The returnedTask
can fail with aRemoteException
.
public abstractTask<Intent> getCompareProfileIntentWithAlternativeNameHints (StringotherPlayerId, String otherPlayerInGameName,String currentPlayerInGameName)
Returns aTask
which
asynchronously loads anIntent
that
will display a screen where the user can see a comparison of their own profile against
another player's profile. Note that theIntent
returned from the
Task
must be invoked with
Activity.startActivityForResult(Intent, int)
,so that the identity of the
calling package can be established.
Note that PGS gamer tags should not be provided as the "alternative" name. This form
of#getCompareProfileIntent
should be used when the game has its own
player names separate from the Play Games Services gamer tag. These names will be used
in the profile display and only sent to the server if the player initiates a friend
invitation to the profile being viewed, so that the sender and recipient have context
relevant to their game experience.
Parameters
otherPlayerId | The player ID of the player to compare with. |
---|---|
otherPlayerInGameName | The game's own display name of the player referred to by otherPlayerId. |
currentPlayerInGameName | The game's own display name of the current player. |
public abstractTask<AnnotatedData<Player>> getCurrentPlayer(boolean forceReload)
Returns aTask
which
asynchronously loads the current signed-inPlayer
,
if available.
The returnedTask
can fail with aRemoteException
.
Parameters
forceReload | Iftrue ,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 tofalse
to gain advantages of data caching. |
---|
public abstractTask<Player> getCurrentPlayer()
Returns aTask
which
asynchronously loads the current signed-inPlayer
,
if available.
The returnedTask
can fail with aRemoteException
.
public abstractTask<String> getCurrentPlayerId()
Returns aTask
which
asynchronously loads the current signed-in player ID, if available.
The returnedTask
can fail with aRemoteException
.
public abstractTask<Intent> getPlayerSearchIntent()
Returns aTask
which
asynchronously loads anIntent
that
will display a screen where the user can search for players.
Note that this must be invoked with
Activity.startActivityForResult(Intent, int)
,so that the identity of the
calling package can be established.
If the user canceled, the result will beActivity.RESULT_CANCELED
.
If the user selected any players from the search results list, the result will be
Activity.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 returnedTask
can fail with aRemoteException
.
public abstractTask<AnnotatedData<PlayerBuffer>> loadFriends(int pageSize, boolean forceReload)
Returns aTask
which
asynchronously loads an annotatedPlayerBuffer
that represents friends the user has.
This call will fail with
FriendsResolutionRequiredException
if the user has not granted the game
access to their friends list. The exception result can be used to ask for consent.
AbstractDataBuffer.release()
should be called to release resources after
usage.
Parameters
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. |
---|---|
forceReload | Iftrue ,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 tofalse
to gain advantages of data caching. |
public abstractTask<AnnotatedData<PlayerBuffer>> loadMoreFriends(int pageSize)
Returns aTask
which
asynchronously loads an annotatedPlayerBuffer
that represents friends the user has. ThePlayerBuffer
will contain an extra page of results.
This call will fail with
FriendsResolutionRequiredException
if the user has not granted the game
access to their friends list. The exception result can be used to ask for consent.
AbstractDataBuffer.release()
should be called to release resources after
usage.
Parameters
pageSize | The number of additional entries to request. |
---|
public abstractTask<AnnotatedData<PlayerBuffer>> loadMoreRecentlyPlayedWithPlayers(int pageSize)
This method is deprecated.
Real-time multiplayer and Turn-based multiplayer support is being shut down on March 31,
2020. SeeMultiplayer
deprecation
Returns aTask
which
asynchronously loads an annotatedPlayerBuffer
that represents players the user has interacted with recently, starting with the most
recent.
AbstractDataBuffer.release()
should be called to release resources after
usage.
Parameters
pageSize | The number of additional entries to request. This must be a value between 1 and 25. |
---|
public abstractTask<AnnotatedData<Player>> loadPlayer(StringplayerId, boolean forceReload)
Returns aTask
which
asynchronously loads an annotatedPlayer
profile specified byplayerId
.
The returnedTask
can fail with aRemoteException
.
Parameters
playerId | The player ID to get full profile data for. |
---|---|
forceReload | Iftrue ,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 tofalse
to gain advantages of data caching. |
public abstractTask<AnnotatedData<Player>> loadPlayer(StringplayerId)
Returns aTask
which
asynchronously loads an annotatedPlayer
profile specified byplayerId
.
Returns the locally-cached player if available.
The returnedTask
can fail with aRemoteException
.
Parameters
playerId | The player ID to get full profile data for. |
---|
public abstractTask<AnnotatedData<PlayerBuffer>> loadRecentlyPlayedWithPlayers(int pageSize, boolean forceReload)
This method is deprecated.
Real-time multiplayer and Turn-based multiplayer support is being shut down on March 31,
2020. SeeMultiplayer
deprecation
Returns aTask
which
asynchronously loads an annotatedPlayerBuffer
that represents players the user has interacted with recently, starting with the most
recent.
AbstractDataBuffer.release()
should be called to release resources after
usage.
Parameters
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 | Iftrue ,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 tofalse
to gain advantages of data caching. |