如何打开"所有"默认情况下,而不是"社交"在谷歌排行榜?

时间:2016-05-24 13:32:30

标签: google-play google-play-services google-play-games leaderboard google-play-developer-api

我在我的Android游戏应用中集成了Google Leaderboard。当我打开它时,它会进入" Social"默认模式(也就是我的Google圈子)。我需要手动切换到" All"模式(来自世界各地的玩家)。我该如何制作" All"模式默认?

2 个答案:

答案 0 :(得分:1)

有一个重载方法,它接受所有参数:getLeaderboardIntent (GoogleApiClient apiClient, String leaderboardId, int timeSpan, int collection)

您可以通过以下方式获取意图并显示所有排行榜:

Intent intent = Games.Leaderboards.getLeaderboardIntent(apiClient,
     leaderboardId, LeaderboardVariant.TIME_SPAN_ALL_TIME,
     LeaderboardVariant.COLLECTION_PUBLIC);

// REQUEST_LEADERBOARD is an arbitrary constant to check for in onActivityResult
activity.startActivityForResult(intent, REQUEST_LEADERBOARD);

有关详细信息,请参阅:https://developers.google.com/games/services/android/leaderboards#displaying_a_leaderboard

答案 1 :(得分:1)

根据谷歌文档,克莱顿的以下答案看起来很完美。 但是我认为谷歌文档和Leaderboard类之间存在不匹配。

如果你尝试:Games.Leaderboards.getLeaderboardIntent(GoogleApiClient apiClient,String leaderboardId)它可以工作。

如果您尝试:Games.Leaderboards.getLeaderboardIntent(GoogleApiClient apiClient,String leaderboardId,int timeSpan)它可以工作,但无论int值如何,您将在“所有时间”基础上拥有排行榜。

如果您尝试(应该是您的anwser):Games.Leaderboards.getLeaderboardIntent(GoogleApiClient apiClient,String leaderboardId,int timeSpan,int collection)它不起作用(该方法不存在)。

为了说明“不存在”的含义,您可以查看我们的Leaderboard类应该是什么(49到51之间的行): https://github.com/gamea-fiks/ccc/blob/62156a697da41733afb23a63beed05e3b17a5784/sources/com/google/android/gms/games/leaderboard/Leaderboards.java

Stackoverflow上的另一个问题也是关于这个问题:How to show public collection from google leaderboard with getLeaderboardIntent()?

顺便说一下,我们希望很快就能得到纠正(或者说我错了)!