目录

The Player class is used to return the specific information about a player. When the PlayersClient.getCurrentPlayer method is called, an instance of the Player type is returned.

Public Method Summary

ReturnMethod
StringgetDisplayName()
Obtains the player nickname.
UrigetHiResImageUri()
Obtains the URI of the high-resolution profile image of a player.
UrigetIconImageUri()
Obtains the URI of the icon-size profile image of a player.
intgetLevel()
Obtains the player level information. Currently, this method can obtain only the level information about players in Chinese Mainland. For players outside Chinese Mainland, this method returns 1.
StringgetPlayerId()
Obtains the game account ID assigned by Huawei to a player. The ID uniquely identifies the player in the app.
booleanhasHiResImage()
Checks whether the player has a high-resolution profile image.
booleanhasIconImage()
Checks whether the player has an icon-size profile image.
StringgetPlayerSign()
Obtains the sign-in signature of a player. The app server can call the Verifying Login Signature API based on the sign-in signature to verify the player ID on the Huawei server.
StringgetSignTs()
Obtains the timestamp information to be submitted during sign-in signature verification.

Public Methods

public String getDisplayName()

Obtains the player nickname. 

Return Values

typedescription
StringString of the player nickname displayed in the game.

public Uri getHiResImageUri()

Obtains the URI of the high-resolution profile image of a player. The URI needs to be obtained only when the hasHiResImage() method returns true.

Return Values

typedescription
UriURI of the high-resolution profile image of a player. If the player does not have a high-resolution profile image, this method returns null.

public Uri getIconImageUri()

Obtains the URI of the icon-size profile image of a player. The URI needs to be obtained only when the hasIconImage() method returns true.

Return Values

typedescription
UriURI of the icon-size profile image of a player. If the player does not have a profile image, this method returns null.

public int getLevel()

Obtains the player level information. Currently, this method can obtain only level information about players in Chinese Mainland. For players outside Chinese Mainland, this method returns 1.

Return Values

typedescription
intThe player level. If a player has no level information or is not in the Chinese Mainland, 1 is returned.

public String getPlayerId()

Obtains the player ID.

Return Values

typedescription
StringPlayer ID.

public boolean hasHiResImage()

Checks whether the player has a high-resolution profile image.

Return Values

typedescription
boolean● true: The player has a high-resolution profile image. The app can call the getHiResImageUri() method to obtain the URI of the profile image.
● false: The player does not have a high-resolution profile image.

public boolean hasIconImage()

Checks whether the player has an icon-size profile image.

Return Values

typedescription
boolean● true: The player has an icon-size profile image. The app can call the getIconImageUri() method to obtain the URI of the profile image.
● false: The player does not have an icon-size profile image.

public String getPlayerSign()

Obtains the sign-in signature of the player, which is used for initiating sign-in signature verification to the Huawei game server when the app server calls the Verifying Login Signature API.

Return Values

typedescription
StringSign-in signature string.

public String getSignTs()

Obtains the timestamp returned by the Huawei game server, which is used for initiating sign-in signature verification to the Huawei game server when the app server calls the Verifying Login Signature API.

Return Values

typedescription
StringTimestamp string. By default, the timestamp is valid for five minutes. The sign-in signature must be verified when the timestamp is valid. Otherwise, the sign-in signature fails the verification.