目录

Player

Class Info

public class Player extends Object

Player类主要用于返回游戏玩家的具体信息,在调用PlayersClient.getCurrentPlayer方法时会返回Player类型的实例。

Public Method Summary

Qualifier and Type

Method Name and Description

String

getDisplayName()

获取玩家昵称。

Uri

getHiResImageUri()

获取玩家高清头像的URI地址。

Uri

getIconImageUri()

获取玩家普通图标头像的URI地址。

int

getLevel()

获取玩家等级信息,当前只支持中国大陆玩家,中国大陆以外的玩家将默认返回1。

String

getPlayerId()

获取华为为玩家分配的游戏帐户ID,该ID可在应用内唯一标识该用户。

boolean

hasHiResImage()

检查玩家是否存在高清头像。

boolean

hasIconImage()

检查玩家是否存在普通头像。

String

getPlayerSign()

获取玩家的登录签名,应用服务端可以根据登录签名调用校验登录签名接口向华为游戏服务器验证玩家信息的有效性。

String

getSignTs()

获取校验登录签名时需要提交的时间戳信息。

String

getOpenId()

获取用户在应用中的openId。同一个用户在不同应用中的openId值不同。使用openId标识用户,多个应用之间同一个华为帐号用户在开发者系统内会被标识为多个用户。

String

getUnionId()

获取用户的unionId。unionId是开发者帐号ID,对于同一个用户,同一个开发者帐号下管理的不同应用,unionId值相同。如果一个应用转移到另外一个帐号后,unionId值也会变化。

String

getOpenIdSign()

获取openId的登录签名,应用服务端可以根据登录签名调用校验登录签名接口向华为游戏服务器验证playerId和openId对应关系的准确性。

Public Methods

[h2]getDisplayName

Method

public String getDisplayName()

获取玩家昵称。

Returns

Type

Description

String

用于游戏展示的玩家昵称。

免授权登录场景下无法获取玩家昵称。

[h2]getHiResImageUri

Method

public Uri getHiResImageUri()

获取玩家高清头像的URI地址,hasHiResImage()方法返回true时才需要获取。

Returns

Type

Description

Uri

玩家高清头像的URI地址。如果玩家不存在高清头像,返回null。

如果此方法获取不到玩家头像,建议从登录成功后返回的AuthHuaweiId或AuthAccount获取。免授权登录场景下无法获取玩家头像。

[h2]getIconImageUri

Method

public Uri getIconImageUri()

获取玩家普通图标头像的URI地址,hasIconImage()方法返回true才需要获取。

Returns

Type

Description

Uri

玩家普通图标头像的URI地址。如果玩家没有头像,返回null。

如果此方法获取不到玩家头像,建议从登录成功后返回的AuthHuaweiId或AuthAccount获取。免授权登录场景下无法获取玩家头像。

[h2]getLevel

Method

public int getLevel()

获取玩家等级。当前只支持注册地为中国大陆玩家,中国大陆以外的玩家将默认返回1。

Returns

Type

Description

int

返回玩家等级数字。

[h2]getPlayerId

Method

public String getPlayerId()

获取玩家ID。如果开发者帐号下管理多个游戏,返回的playerId相同。

Returns

Type

Description

String

玩家ID。

[h2]hasHiResImage

Method

public boolean hasHiResImage()

玩家是否存在高清头像。

Returns

Type

Description

boolean

玩家是否存在高清头像。

  • true:存在。如果存在可调用getHiResImageUri()方法获取头像的URI地址。
  • false:不存在。

[h2]hasIconImage

Method

public boolean hasIconImage()

玩家是否存在普通图标头像。

Returns

Type

Description

boolean

玩家是否存在普通图标头像。

  • true:存在。如果存在可调用getIconImageUri()方法获取头像的URI地址。
  • false:不存在。

[h2]getPlayerSign

Method

public String getPlayerSign()

获取玩家的登录签名,用于应用服务端调用校验登录签名接口时向华为游戏服务器发起登录签名验证。

Returns

Type

Description

String

登录签名字符串。

[h2]getSignTs

Method

public String getSignTs()

获取华为游戏服务器返回的时间戳,用于应用服务端调用校验登录签名接口时向华为游戏服务器发起登录签名验证。

Returns

Type

Description

String

时间戳字符串。时间戳的有效时间默认为5分钟,请在有效期内完成登录签名校验,否则将导致登录签名校验失败。

[h2]getOpenId

Method

public String getOpenId()

获取用户的openId。同一个用户,不同应用,openId值不同。使用openId标识用户,多个应用之间同一个华为帐号用户在开发者系统内会被标识为多个用户。

Returns

Type

Description

String

用户的OpenId。

[h2]getUnionId

Method

public String getUnionId()

获取用户的unionId。unionId是开发者帐号ID,对于同一个用户,同一个开发者帐号下管理的不同应用,unionId值相同。如果一个应用转移到另外一个帐号后,unionId值也会变化。

unionId和openId的区别在于,如果开发者帐号下管理了多个应用,针对同一个华为帐号,不同的应用返回的openId值不同,但返回的unionId相同。如果开发者需要在不同应用中共享同一个华为帐号的用户信息,可以使用unionId作为用户标识。

Returns

Type

Description

String

用户的UnionId。

[h2]getOpenIdSign

Method

public String getOpenIdSign()

获取openId的登录签名,应用服务端可以根据登录签名调用校验登录签名接口向华为游戏服务器验证playerId和openId对应关系的准确性。

Returns

Type

Description

String

签名字符串。