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.
GamesClient
Stay organized with collections
Save and categorize content based on your preferences.
A client to interact with games basic functionality.
Public Method Summary
abstract Task
< Bundle
> |
getActivationHint
() Returns a Task
which asynchronously loads a Bundle
that may contain an information regarding to the previous user's action.
|
abstract Task
< String
> |
getAppId
() Returns a Task
which asynchronously loads the application ID linked to this client instance.
|
abstract Task
< String
> |
|
abstract Task
< Intent
> |
getSettingsIntent
() Returns a Task
which asynchronously loads an Intent
to show the Settings screen that allows the user to configure Games-related
features for the current game.
|
abstract Task
< Void
> |
setGravityForPopups
(int gravity) Returns a Task
which asynchronously sets the part of the screen at which games service pop-ups
(for example, "welcome back" or "achievement unlocked" popups) will be
displayed using gravity.
|
abstract Task
< Void
> |
|
Public Methods
public abstract Task
< Bundle
>
getActivationHint
()
Returns a Task
which
asynchronously loads a Bundle
that may
contain an information regarding to the previous user's action.
The Task
returned will not be null, but the Bundle
returned from the Task
may be null if it was already received or there is
no related data found.
Unless a new user action is performed all the subsequent calls will return a Task
with a null Bundle
.
A Bundle
can contain the following keys:
public abstract Task
< String
>
getAppId
()
Returns a Task
which
asynchronously loads the application ID linked to this client instance.
public abstract Task
< String
>
getCurrentAccountName
()
Returns a Task
which
asynchronously loads the name of the currently selected account. This is the account
the user has chosen to use for Google Play Games.
The returned Task
can fail with a RemoteException
.
Note that your app must have <uses-permission
android:name="android.permission.GET_ACCOUNTS" />
declared in your manifest
in order to use this method. Otherwise the Task
will fail with SecurityException
.
public abstract Task
< Intent
>
getSettingsIntent
()
Returns a Task
which
asynchronously loads an Intent
to
show the Settings screen that allows the user to configure Games-related features for
the current game. Note that this must be invoked with Activity.startActivityForResult(Intent, int)
, so that the identity of the
calling package can be established.
The returned Task
can fail with a RemoteException
.
Most applications will not need to call this directly, since the Settings UI is
already reachable from most other Games UI screens (achievements, leaderboards, etc.)
via a menu item.
Returns a Task
which
asynchronously sets the part of the screen at which games service pop-ups (for example,
"welcome back" or "achievement unlocked" popups) will be displayed using gravity.
Default value is Gravity.TOP
| Gravity.CENTER_HORIZONTAL
.
Parameters
gravity
The gravity which controls the placement of games service pop-ups.
Returns a Task
which
asynchronously sets the View
to use as a
content view for popups.
Parameters
gamesContentView
The view to use as a content view for popups. View cannot be null.
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.
[[["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 2025-01-24 UTC."],[[["\u003cp\u003e\u003ccode\u003eGamesClient\u003c/code\u003e provides methods to interact with basic Google Play games services functionality.\u003c/p\u003e\n"],["\u003cp\u003eIt allows retrieval of application ID, current account name, and an activation hint related to the previous user's action.\u003c/p\u003e\n"],["\u003cp\u003eIt enables setting the gravity and view for game service pop-ups, like "achievement unlocked" messages.\u003c/p\u003e\n"],["\u003cp\u003eYou can obtain an Intent to launch the Games Settings screen for user configuration of game-related features.\u003c/p\u003e\n"],["\u003cp\u003eAsynchronous operations are performed using \u003ccode\u003eTasks\u003c/code\u003e, ensuring non-blocking execution.\u003c/p\u003e\n"]]],["The `GamesClient` interface provides methods to interact with game functionalities. It enables retrieving an activation hint (`getActivationHint`), the application ID (`getAppId`), and the current account name (`getCurrentAccountName`). It also provides the functionality to get settings screen `Intent` (`getSettingsIntent`), setting the gravity for pop-ups (`setGravityForPopups`), and setting the view for pop-ups (`setViewForPopups`). All these methods return asynchronous `Task` objects for data loading or actions.\n"],null,["# GamesClient\n\npublic interface **GamesClient** \nA client to interact with games basic functionality. \n\n### Public Method Summary\n\n|--------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Task](/android/reference/com/google/android/gms/tasks/Task)\\\u003c[Bundle](//developer.android.com/reference/android/os/Bundle.html)\\\u003e | [getActivationHint](/android/games_v1/reference/com/google/android/gms/games/GamesClient#getActivationHint())() Returns a [Task](/android/reference/com/google/android/gms/tasks/Task) which asynchronously loads a [Bundle](//developer.android.com/reference/android/os/Bundle.html) that may contain an information regarding to the previous user's action. |\n| abstract [Task](/android/reference/com/google/android/gms/tasks/Task)\\\u003c[String](//developer.android.com/reference/java/lang/String.html)\\\u003e | [getAppId](/android/games_v1/reference/com/google/android/gms/games/GamesClient#getAppId())() Returns a [Task](/android/reference/com/google/android/gms/tasks/Task) which asynchronously loads the application ID linked to this client instance. |\n| abstract [Task](/android/reference/com/google/android/gms/tasks/Task)\\\u003c[String](//developer.android.com/reference/java/lang/String.html)\\\u003e | [getCurrentAccountName](/android/games_v1/reference/com/google/android/gms/games/GamesClient#getCurrentAccountName())() Returns a [Task](/android/reference/com/google/android/gms/tasks/Task) which asynchronously loads the name of the currently selected account. |\n| abstract [Task](/android/reference/com/google/android/gms/tasks/Task)\\\u003c[Intent](//developer.android.com/reference/android/content/Intent.html)\\\u003e | [getSettingsIntent](/android/games_v1/reference/com/google/android/gms/games/GamesClient#getSettingsIntent())() Returns a [Task](/android/reference/com/google/android/gms/tasks/Task) which asynchronously loads an [Intent](//developer.android.com/reference/android/content/Intent.html) to show the Settings screen that allows the user to configure Games-related features for the current game. |\n| abstract [Task](/android/reference/com/google/android/gms/tasks/Task)\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e | [setGravityForPopups](/android/games_v1/reference/com/google/android/gms/games/GamesClient#setGravityForPopups(int))(int gravity) Returns a [Task](/android/reference/com/google/android/gms/tasks/Task) which asynchronously sets the part of the screen at which games service pop-ups (for example, \"welcome back\" or \"achievement unlocked\" popups) will be displayed using gravity. |\n| abstract [Task](/android/reference/com/google/android/gms/tasks/Task)\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e | [setViewForPopups](/android/games_v1/reference/com/google/android/gms/games/GamesClient#setViewForPopups(android.view.View))([View](//developer.android.com/reference/android/view/View.html) gamesContentView) Returns a [Task](/android/reference/com/google/android/gms/tasks/Task) which asynchronously sets the [View](//developer.android.com/reference/android/view/View.html) to use as a content view for popups. |\n\nPublic Methods\n--------------\n\n#### public abstract [Task](/android/reference/com/google/android/gms/tasks/Task)\\\u003c[Bundle](//developer.android.com/reference/android/os/Bundle.html)\\\u003e\n**getActivationHint** ()\n\nReturns a [Task](/android/reference/com/google/android/gms/tasks/Task) which\nasynchronously loads a [Bundle](//developer.android.com/reference/android/os/Bundle.html) that may\ncontain an information regarding to the previous user's action.\n\nThe `Task` returned will not be null, but the `Bundle`\nreturned from the `Task` may be null if it was already received or there is\nno related data found.\n\nUnless a new user action is performed all the subsequent calls will return a\n`Task` with a null `Bundle`.\n\nA `Bundle` can contain the following keys:\n\n- [SnapshotsClient.EXTRA_SNAPSHOT_METADATA](/android/games_v1/reference/com/google/android/gms/games/SnapshotsClient#EXTRA_SNAPSHOT_METADATA) if the user wanted to resume a saved game. The value contained here is a [SnapshotMetadata](/android/games_v1/reference/com/google/android/gms/games/snapshot/SnapshotMetadata) object which can be accessed with [Bundle.getParcelable(String)](//developer.android.com/reference/android/os/Bundle.html#getParcelable(java.lang.String)). \n\n#### public abstract [Task](/android/reference/com/google/android/gms/tasks/Task)\\\u003c[String](//developer.android.com/reference/java/lang/String.html)\\\u003e\n**getAppId** ()\n\nReturns a [Task](/android/reference/com/google/android/gms/tasks/Task) which\nasynchronously loads the application ID linked to this client instance. \n\n#### public abstract [Task](/android/reference/com/google/android/gms/tasks/Task)\\\u003c[String](//developer.android.com/reference/java/lang/String.html)\\\u003e\n**getCurrentAccountName** ()\n\nReturns a [Task](/android/reference/com/google/android/gms/tasks/Task) which\nasynchronously loads the name of the currently selected account. This is the account\nthe user has chosen to use for Google Play Games.\n\nThe returned `Task` can fail with a [RemoteException](//developer.android.com/reference/android/os/RemoteException.html).\n\nNote that your app must have `\u003cuses-permission\nandroid:name=\"android.permission.GET_ACCOUNTS\" /\u003e` declared in your manifest\nin order to use this method. Otherwise the `Task` will fail with\n[SecurityException](//developer.android.com/reference/java/lang/SecurityException.html). \n\n#### public abstract [Task](/android/reference/com/google/android/gms/tasks/Task)\\\u003c[Intent](//developer.android.com/reference/android/content/Intent.html)\\\u003e\n**getSettingsIntent** ()\n\nReturns a [Task](/android/reference/com/google/android/gms/tasks/Task) which\nasynchronously loads an [Intent](//developer.android.com/reference/android/content/Intent.html) to\nshow the Settings screen that allows the user to configure Games-related features for\nthe current game. Note that this must be invoked with [Activity.startActivityForResult(Intent, int)](//developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent,%20int)), so that the identity of the\ncalling package can be established.\n\nThe returned `Task` can fail with a [RemoteException](//developer.android.com/reference/android/os/RemoteException.html).\n\nMost applications will not need to call this directly, since the Settings UI is\nalready reachable from most other Games UI screens (achievements, leaderboards, etc.)\nvia a menu item. \n\n#### public abstract [Task](/android/reference/com/google/android/gms/tasks/Task)\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e **setGravityForPopups** (int gravity)\n\nReturns a [Task](/android/reference/com/google/android/gms/tasks/Task) which\nasynchronously sets the part of the screen at which games service pop-ups (for example,\n\"welcome back\" or \"achievement unlocked\" popups) will be displayed using gravity.\n\nDefault value is [Gravity.TOP](//developer.android.com/reference/android/view/Gravity.html#TOP)\\|[Gravity.CENTER_HORIZONTAL](//developer.android.com/reference/android/view/Gravity.html#CENTER_HORIZONTAL). \n\n##### Parameters\n\n| gravity | The gravity which controls the placement of games service pop-ups. |\n|---------|--------------------------------------------------------------------|\n\n#### public abstract [Task](/android/reference/com/google/android/gms/tasks/Task)\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e **setViewForPopups** ([View](//developer.android.com/reference/android/view/View.html) gamesContentView)\n\nReturns a [Task](/android/reference/com/google/android/gms/tasks/Task) which\nasynchronously sets the [View](//developer.android.com/reference/android/view/View.html) to use as a\ncontent view for popups. \n\n##### Parameters\n\n| gamesContentView | The view to use as a content view for popups. View cannot be null. |\n|------------------|--------------------------------------------------------------------|"]]