4

I have integrated Google Leaderboard in my android game app. When I open it, it goes to "Social" mode by default (aka my Google circle). I need to manually switch to "All" mode (players from all around the world). How can I make "All" mode default?

4

2 回答 2

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

于 2016-05-24T15:52:48.767 回答
1

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

如果您尝试:Games.Leaderboards.getLeaderboardIntent(GoogleApiClient apiClient, String leaderboardId)它有效。

如果您尝试:Games.Leaderboards.getLeaderboardIntent(GoogleApiClient apiClient, String leaderboardId, int timeSpan)它可以工作,但无论 int 值是多少,您都将拥有一个基于“所有时间”的排行榜。

如果您尝试(您的答案应该是什么):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 上的另一个问题也是关于这个问题的:https ://stackoverflow.com/questions/32867659/how-to-show-public-collection-from-google-leaderboard-with-getleaderboardintent

顺便说一句,我们希望它会很快得到纠正(或者我在某个地方错了)!

于 2016-06-10T18:26:43.623 回答