目录

The GamePlayerStatisticsClient class defines the APIs related to player information statistics.

Public Method Summary

Return

Method

Task<GamePlayerStatistics>

getGamePlayerStatistics(boolean isRealTime)

Obtains the statistics of the current player, such as the session duration and rank.

Public Methods

public Task<GamePlayerStatistics> getGamePlayerStatistics(boolean isRealTime)

Obtains the statistics of the current player asynchronously, such as the session duration and rank. The statistics can be obtained from the local cache or Huawei game server.

Input Parameters

Parameter Name

Parameter Description

isRealTime

Indicates whether to obtain data from Huawei game server.

  • true: Obtain data from Huawei game server.

  • false: Obtain data from the local cache. Data is kept in the local cache for 5 minutes. If there is no local cache or the cache times out, data will be obtained from the game server.

Return Values

Type

Description

Task<GamePlayerStatistics>

The statistics about the current player.

You need to set two callback listeners in the Task returned by the API. OnSuccessListener obtains the data returned in the success scenario, and OnFailureListener obtains the information about the request failure. In OnFailureListener, you need to check whether the exception object called back in this mode is an ApiException instance object, and resolve the failure according to getStatusCode() contained in the ApiException instance.