Reputation: 57
I would like to display more than one(four) leaderboards if a button is clicked. Well, so that the user can chose which leaderboard he want to see. I'm using Google Play Services, is there any function to do that? At the moment I'm displaying one leaderboard like this:
else if(view.getId() == R.id.show_leaderboard){
startActivityForResult(Games.Leaderboards.getLeaderboardIntent(
getApiClient(), getString(R.string.int_id)),
1);
Where int_id is the leaderboard id. I guess I could use this code 4 times with the right id, but this would be a mess, right?
Upvotes: 2
Views: 1105
Reputation: 18978
You can only display one leaderboard, or all leaderboards (where the user can select the one they want). Use getAllLeaderboardsIntent
instead of getLeaderboardIntent
to show the list of all leaderboards:
startActivityForResult( Games.Leaderboards.getAllLeaderboardsIntent( getApiClient() ), 1 );
I do not think there is a way to display a subset of all leaderboards using the Play Games app - but you can create your own screen with a list where the player can then select the leaderboard to view and you then call the code as per your question for the matching leaderboard.
Upvotes: 7