Leaderboard
Stay organized with collections
Save and categorize content based on your preferences.
Data interface for leaderboard metadata.
Inherited Method Summary
From interface
com.google.android.gms.common.data.Freezable
Constants
public static final int
SCORE_ORDER_LARGER_IS_BETTER
Score order constant for leaderboards where scores are sorted in descending
order.
Constant Value:
1
public static final int
SCORE_ORDER_SMALLER_IS_BETTER
Score order constant for leaderboards where scores are sorted in ascending
order.
Constant Value:
0
Public Methods
public abstract String
getDisplayName
()
Retrieves the display name of this leaderboard.
Returns
- Display name of this leaderboard.
public abstract void
getDisplayName
( CharArrayBuffer
dataOut)
Parameters
dataOut
The buffer to load the data into.
public abstract Uri
getIconImageUri
()
Retrieves an image URI that can be used to load this leaderboard's icon, or null if
there was a problem retrieving the icon.
To retrieve the Image from the Uri
, use ImageManager
.
Returns
- A URI that can be used to load this leaderboard's icon, or null if there was a
problem retrieving the icon.
public abstract String
getLeaderboardId
()
Retrieves the ID of this leaderboard.
Returns
- The ID of this leaderboard.
public abstract int
getScoreOrder
()
Returns
- The score order used by this leaderboard.
Retrieves the LeaderboardVariant
s
for this leaderboard. These will be returned sorted by time span first, then by variant
type.
Note that these variants are volatile, and are tied to the lifetime of the original
buffer.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eLeaderboard\u003c/code\u003e interface provides metadata for game leaderboards, including display name, icon, ID, score order, and variants.\u003c/p\u003e\n"],["\u003cp\u003eIt defines two score order constants: \u003ccode\u003eSCORE_ORDER_LARGER_IS_BETTER\u003c/code\u003e and \u003ccode\u003eSCORE_ORDER_SMALLER_IS_BETTER\u003c/code\u003e to indicate how scores are sorted.\u003c/p\u003e\n"],["\u003cp\u003eMethods like \u003ccode\u003egetDisplayName()\u003c/code\u003e, \u003ccode\u003egetIconImageUri()\u003c/code\u003e, and \u003ccode\u003egetLeaderboardId()\u003c/code\u003e allow access to leaderboard properties.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetVariants()\u003c/code\u003e retrieves a list of \u003ccode\u003eLeaderboardVariant\u003c/code\u003e objects, representing different configurations for the leaderboard.\u003c/p\u003e\n"],["\u003cp\u003eThe interface inherits from \u003ccode\u003eFreezable\u003c/code\u003e, enabling data to be frozen for consistent access.\u003c/p\u003e\n"]]],["The `Leaderboard` interface provides methods to access leaderboard metadata. Key actions include retrieving the leaderboard's `displayName` (either as a String or by loading into `CharArrayBuffer`), `iconImageUri`, and `leaderboardId`. It also provides methods to get the `scoreOrder` (ascending or descending) and a list of `LeaderboardVariant`s. Constants define the possible score orders, and inherited methods allow data freezing and validation.\n"],null,["# Leaderboard\n\npublic interface **Leaderboard** implements [Freezable](/android/reference/com/google/android/gms/common/data/Freezable)\\\u003c[Leaderboard](/android/reference/com/google/android/gms/games/leaderboard/Leaderboard)\\\u003e \nData interface for leaderboard metadata. \n\n### Constant Summary\n\n|-----|----------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|\n| int | [SCORE_ORDER_LARGER_IS_BETTER](/android/reference/com/google/android/gms/games/leaderboard/Leaderboard#SCORE_ORDER_LARGER_IS_BETTER) | Score order constant for leaderboards where scores are sorted in descending order. |\n| int | [SCORE_ORDER_SMALLER_IS_BETTER](/android/reference/com/google/android/gms/games/leaderboard/Leaderboard#SCORE_ORDER_SMALLER_IS_BETTER) | Score order constant for leaderboards where scores are sorted in ascending order. |\n\n### Public Method Summary\n\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [String](//developer.android.com/reference/java/lang/String.html) | [getDisplayName](/android/reference/com/google/android/gms/games/leaderboard/Leaderboard#getDisplayName())() Retrieves the display name of this leaderboard. |\n| abstract void | [getDisplayName](/android/reference/com/google/android/gms/games/leaderboard/Leaderboard#getDisplayName(android.database.CharArrayBuffer))([CharArrayBuffer](//developer.android.com/reference/android/database/CharArrayBuffer.html) dataOut) Loads this leaderboard's display name into the given [CharArrayBuffer](//developer.android.com/reference/android/database/CharArrayBuffer.html). |\n| abstract [Uri](//developer.android.com/reference/android/net/Uri.html) | [getIconImageUri](/android/reference/com/google/android/gms/games/leaderboard/Leaderboard#getIconImageUri())() Retrieves an image URI that can be used to load this leaderboard's icon, or null if there was a problem retrieving the icon. |\n| abstract [String](//developer.android.com/reference/java/lang/String.html) | [getLeaderboardId](/android/reference/com/google/android/gms/games/leaderboard/Leaderboard#getLeaderboardId())() Retrieves the ID of this leaderboard. |\n| abstract int | [getScoreOrder](/android/reference/com/google/android/gms/games/leaderboard/Leaderboard#getScoreOrder())() Retrieves the sort order of scores for this leaderboard. |\n| abstract [ArrayList](//developer.android.com/reference/java/util/ArrayList.html)\\\u003c[LeaderboardVariant](/android/reference/com/google/android/gms/games/leaderboard/LeaderboardVariant)\\\u003e | [getVariants](/android/reference/com/google/android/gms/games/leaderboard/Leaderboard#getVariants())() Retrieves the [LeaderboardVariant](/android/reference/com/google/android/gms/games/leaderboard/LeaderboardVariant)s for this leaderboard. |\n\n### Inherited Method Summary\n\nFrom interface com.google.android.gms.common.data.Freezable \n\n|-------------------------------------------------------------------------------------------------|---------------|\n| abstract [Leaderboard](/android/reference/com/google/android/gms/games/leaderboard/Leaderboard) | freeze() |\n| abstract boolean | isDataValid() |\n\nConstants\n---------\n\n#### public static final int\n**SCORE_ORDER_LARGER_IS_BETTER**\n\nScore order constant for leaderboards where scores are sorted in descending\norder. \nConstant Value: 1 \n\n#### public static final int\n**SCORE_ORDER_SMALLER_IS_BETTER**\n\nScore order constant for leaderboards where scores are sorted in ascending\norder. \nConstant Value: 0\n\nPublic Methods\n--------------\n\n#### public abstract [String](//developer.android.com/reference/java/lang/String.html) **getDisplayName** ()\n\nRetrieves the display name of this leaderboard. \n\n##### Returns\n\n- Display name of this leaderboard. \n\n#### public abstract void **getDisplayName** ([CharArrayBuffer](//developer.android.com/reference/android/database/CharArrayBuffer.html) dataOut)\n\nLoads this leaderboard's display name into the given [CharArrayBuffer](//developer.android.com/reference/android/database/CharArrayBuffer.html). \n\n##### Parameters\n\n| dataOut | The buffer to load the data into. |\n|---------|-----------------------------------|\n\n#### public abstract [Uri](//developer.android.com/reference/android/net/Uri.html) **getIconImageUri** ()\n\nRetrieves an image URI that can be used to load this leaderboard's icon, or null if\nthere was a problem retrieving the icon.\n\nTo retrieve the Image from the [Uri](//developer.android.com/reference/android/net/Uri.html), use\n[ImageManager](/android/reference/com/google/android/gms/common/images/ImageManager). \n\n##### Returns\n\n- A URI that can be used to load this leaderboard's icon, or null if there was a problem retrieving the icon. \n\n#### public abstract [String](//developer.android.com/reference/java/lang/String.html) **getLeaderboardId** ()\n\nRetrieves the ID of this leaderboard. \n\n##### Returns\n\n- The ID of this leaderboard. \n\n#### public abstract int **getScoreOrder** ()\n\nRetrieves the sort order of scores for this leaderboard. Possible values are\n[SCORE_ORDER_LARGER_IS_BETTER](/android/reference/com/google/android/gms/games/leaderboard/Leaderboard#SCORE_ORDER_LARGER_IS_BETTER) or [SCORE_ORDER_SMALLER_IS_BETTER](/android/reference/com/google/android/gms/games/leaderboard/Leaderboard#SCORE_ORDER_SMALLER_IS_BETTER). \n\n##### Returns\n\n- The score order used by this leaderboard. \n\n#### public abstract [ArrayList](//developer.android.com/reference/java/util/ArrayList.html)\\\u003c[LeaderboardVariant](/android/reference/com/google/android/gms/games/leaderboard/LeaderboardVariant)\\\u003e\n**getVariants** ()\n\nRetrieves the [LeaderboardVariant](/android/reference/com/google/android/gms/games/leaderboard/LeaderboardVariant)s\nfor this leaderboard. These will be returned sorted by time span first, then by variant\ntype.\n\nNote that these variants are volatile, and are tied to the lifetime of the original\nbuffer. \n\n##### Returns\n\n- A list containing the [LeaderboardVariant](/android/reference/com/google/android/gms/games/leaderboard/LeaderboardVariant)s for this leaderboard."]]