Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display a leaderboard with google play game services?

I have a game set up and connected in the developer console. Login works, submitting scores to the leaderboard works as well.

Now I simply don't understand the instructions on displaying the leaderboard https://developers.google.com/games/services/android/leaderboards#displaying_a_leaderboard

the sample code is:

startActivityForResult(mGamesClient.getLeaderboardIntent(LEADERBOARD_ID), REQUEST_LEADERBOARD);

where everything is fine but what does the constant REQUEST_LEADERBOARD stand for, or where is it defined if it already exists?

Thanks

EDIT: I should not have skipped the achievements-tutorial where it says: In the example, REQUEST_ACHIEVEMENTS is an arbitrary integer that you define as the request code. So I assume that the same applies to the integer REQUEST_LEADERBOARD.

EDIT 2: It is an arbitrary integer that you define as the request code and works fine.

like image 652
Björn Kechel Avatar asked May 17 '13 15:05

Björn Kechel


People also ask

How do I add a Google leaderboard?

To create a leaderboard for a new and unpublished game, go to the Google Play Console entry for your game, and navigate to Grow > Play Games Services > Setup and management > Leaderboards, then click the Create leaderboard button.

What is a game leaderboard?

The term leaderboard is often used in the video gaming industry to signify rank among people who play various titles. Players can be ranked against other players based on their number of kills (most common), items collected, or some other metric.


1 Answers

The request code REQUEST_LEADERBOARD is indeed an arbitrary int that you define by yourself.

You can use it in the notification method onActivityResult(int requestCode, int resultCode, Intent data) of your activity to get notified of the result of the intent.

like image 117
Alexis Pautrot Avatar answered Oct 22 '22 09:10

Alexis Pautrot