如何使用Google游戏服务获取Android中与游戏相关的玩家?

时间:2014-11-03 04:09:51

标签: android google-play-games

我试过这段代码

Games.Players.loadMoreRecentlyPlayedWithPlayers(
                        mGoogleApiClient, 20);

但我不确定如何使用它。

1 个答案:

答案 0 :(得分:0)

我得到了我的答案,我可以取我最近的游戏玩家。

PendingResult<Players.LoadPlayersResult> loadplayers = Games.Players
         .loadMoreRecentlyPlayedWithPlayers(mGoogleApiClient, 20);
loadplayers.setResultCallback(new ResultCallback<Players.LoadPlayersResult>() {

    @Override
    public void onResult(LoadPlayersResult loadplayersResult) {

        if (loadplayersResult != null) {
            if (loadplayersResult.getStatus().getStatusCode() == GamesStatusCodes.STATUS_OK) {
                if (loadplayersResult.getPlayers() != null) {
                    PlayerBuffer plyersBufr = loadplayersResult.getPlayers();
                    for (Player p : plyersBufr) {
                        Log.d(TAG, p.getDisplayName() + "  " + p.getTitle()+"  "
                                    + p.getLastPlayedWithTimestamp() + "  " + p.getLevelInfo());
                    }
                }
            }
        }
    }
});

无论如何,谢谢:)