我已经在我的android游戏应用程序中集成了谷歌排行榜。当我打开它时,默认情况下它会进入“社交”模式(也就是我的谷歌圈子)。我需要手动切换到“所有”模式(来自世界各地的玩家)。如何将"All“模式设为默认值?
发布于 2016-05-24 23:52:49
有一个接受所有参数的重载方法: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-06-11 02:26:44
根据谷歌文档,来自Clayton的以下答案看起来很完美。然而,我认为google文档和排行榜类之间存在不匹配。
如果你尝试一下:Games.Leaderboards.getLeaderboardIntent(GoogleApiClient apiClient, String leaderboardId),它是有效的。
如果你尝试:Games.Leaderboards.getLeaderboardIntent(GoogleApiClient apiClient, String leaderboardId, int timeSpan),它是有效的,但是不管int值是什么,你都会得到一个基于"All time“的排行榜。
如果您尝试(应该是您的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
关于堆栈溢出的另一个问题也是关于这个问题的:https://stackoverflow.com/questions/32867659/how-to-show-public-collection-from-google-leaderboard-with-getleaderboardintent
顺便说一句,让我们希望它很快就会被纠正(或者我在什么地方错了)!
https://stackoverflow.com/questions/37415206
复制相似问题