【问题标题】:How to open "All" by default instead of "Social" in Google Leaderboard?如何在 Google 排行榜中默认打开“全部”而不是“社交”?
【发布时间】:2016-09-21 18:19:18
【问题描述】:

我已在我的 Android 游戏应用中集成了 Google 排行榜。当我打开它时,它默认进入“社交”模式(又名我的 Google 圈子)。我需要手动切换到“全部”模式(来自世界各地的玩家)。如何将“全部”模式设为默认?

【问题讨论】:

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


    【解决方案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

    【讨论】:

    • 确认它总是从社交开始。我提交了一个错误以最终修复它。
    【解决方案2】:

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

    如果你尝试: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 的另一个问题也是关于这个问题的:https://stackoverflow.com/questions/32867659/how-to-show-public-collection-from-google-leaderboard-with-getleaderboardintent

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

    【讨论】:

      猜你喜欢
      • 2015-08-23
      • 2014-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-21
      • 2014-09-10
      • 2014-03-25
      • 1970-01-01
      相关资源
      最近更新 更多