Following the deprecation of the Google Sign-In API, we are removing the games v1 SDK in 2026. After February 2025, you will be unable to publish titles that are newly integrated with games v1 SDK, on Google Play. We recommend that you use the games v2 SDK instead.
While existing titles with the previous games v1 integrations continue to function for a couple of years, you are encouraged to migrate to v2 starting June 2025.
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
abstract
Leaderboard
|
freeze()
|
abstract boolean |
isDataValid()
|
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 2025-01-24 UTC.
[null,null,["Last updated 2025-01-24 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eLeaderboard\u003c/code\u003e interface provides metadata about a leaderboard, such as its display name, ID, icon, and score order.\u003c/p\u003e\n"],["\u003cp\u003eLeaderboards can be sorted in ascending or descending order, indicated by the \u003ccode\u003eSCORE_ORDER_SMALLER_IS_BETTER\u003c/code\u003e and \u003ccode\u003eSCORE_ORDER_LARGER_IS_BETTER\u003c/code\u003e constants respectively.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve information about a leaderboard's variants, including time spans and collection types, using the \u003ccode\u003egetVariants()\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eTo display a leaderboard's icon, use the \u003ccode\u003egetIconImageUri()\u003c/code\u003e method in conjunction with the \u003ccode\u003eImageManager\u003c/code\u003e class.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eLeaderboard\u003c/code\u003e interface inherits from \u003ccode\u003eFreezable\u003c/code\u003e, allowing you to create a snapshot of the data for later use.\u003c/p\u003e\n"]]],["The `Leaderboard` interface provides metadata for leaderboards. It defines two score order constants: `SCORE_ORDER_LARGER_IS_BETTER` and `SCORE_ORDER_SMALLER_IS_BETTER`. Key actions include retrieving the leaderboard's display name, which can be loaded into a `CharArrayBuffer`, icon image URI, ID, and score order. It allows for fetching associated `LeaderboardVariant`s, sorted by time span and variant type. Additionally it has methods to `freeze` the data and verify if the `data` is valid.\n"],null,["# Leaderboard\n\npublic interface **Leaderboard** implements [Freezable](/android/reference/com/google/android/gms/common/data/Freezable)\\\u003c[Leaderboard](/android/games_v1/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/games_v1/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/games_v1/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/games_v1/reference/com/google/android/gms/games/leaderboard/Leaderboard#getDisplayName())() Retrieves the display name of this leaderboard. |\n| abstract void | [getDisplayName](/android/games_v1/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/games_v1/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/games_v1/reference/com/google/android/gms/games/leaderboard/Leaderboard#getLeaderboardId())() Retrieves the ID of this leaderboard. |\n| abstract int | [getScoreOrder](/android/games_v1/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/games_v1/reference/com/google/android/gms/games/leaderboard/LeaderboardVariant)\\\u003e | [getVariants](/android/games_v1/reference/com/google/android/gms/games/leaderboard/Leaderboard#getVariants())() Retrieves the [LeaderboardVariant](/android/games_v1/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/games_v1/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/games_v1/reference/com/google/android/gms/games/leaderboard/Leaderboard#SCORE_ORDER_LARGER_IS_BETTER) or [SCORE_ORDER_SMALLER_IS_BETTER](/android/games_v1/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/games_v1/reference/com/google/android/gms/games/leaderboard/LeaderboardVariant)\\\u003e\n**getVariants** ()\n\nRetrieves the [LeaderboardVariant](/android/games_v1/reference/com/google/android/gms/games/leaderboard/LeaderboardVariant)s for this leaderboard. These will be returned sorted by\ntime span first, then by variant type.\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/games_v1/reference/com/google/android/gms/games/leaderboard/LeaderboardVariant)s for this leaderboard."]]