Reputation: 239
In the documentation the code snippet to display leaderboard is
startActivityForResult(Games.Leaderboards.getLeaderboardIntent(getApiClient(), LEADERBOARD_ID), REQUEST_LEADERBOARD);
This goes into the given leaderboard with LEADERBOARD_ID
My game has severel leaderboards and what I want to do is display a list of them so that user can select a specific leaderboard.
Is it possible to do that?
Upvotes: 14
Views: 3450
Reputation: 4083
This is the new way of doing it:
Games.getLeaderboardsClient(this, GoogleSignIn.getLastSignedInAccount(this)!!)
.allLeaderboardsIntent
.addOnSuccessListener { intent ->
startActivityForResult(
intent,
RC_LEADERBOARD_UI
)
}
companion object{
private const val RC_LEADERBOARD_UI = 9004
}
Upvotes: 1
Reputation: 1528
If you want to use the default UI, you can use this:
startActivityForResult(Games.Leaderboards.getAllLeaderboardsIntent(getApiClient()), REQUEST_LEADERBOARD);
Upvotes: 20