How to display a leaderboard with google play game services?

北战南征 提交于 2019-12-22 01:39:23

问题


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.


回答1:


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.




回答2:


just define any int example REQUEST_LEADERBOARD = 100;



来源:https://stackoverflow.com/questions/16613254/how-to-display-a-leaderboard-with-google-play-game-services

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!