Achievements | Android Developers

Quicknav Quicknav
Links

- Google Play Developer Console
- Android Developers Blog
- About Android

Android Sites

- Android.com
- Android Developers
- Android Open Source Project

Language
close

- - About
  - Wear
  - TV
  - Auto
- - Get Started
  - Devices
  - Style
  - Patterns
  - Building Blocks
  - Downloads
  - Videos
- - Training
  - API Guides
  - Reference
  - Tools
  - Google Services
  - Samples
- - Google Play
  - Essentials
  - Get Users
  - Engage & Retain
  - Monetize
  - Tools & Reference
  - Developer Stories

## Results

Loading...
public interface

# Achievements

com.google.android.gms.games.achievement.Achievements

## Class Overview

Entry point for achievements functionality.

## Summary

Nested Classes
interface | Achievements.LoadAchievementsResult | Result delivered when achievement data has been loaded.
interface | Achievements.UpdateAchievementResult | Result delivered when achievement data has been updated (revealed, unlocked or incremented).

Public Methods
abstract Intent | getAchievementsIntent(GoogleApiClient apiClient) Gets an intent to show the list of achievements for a game.
abstract void | increment(GoogleApiClient apiClient, String id, int numSteps) Increments an achievement by the given number of steps.
abstract PendingResult<Achievements.UpdateAchievementResult> | incrementImmediate(GoogleApiClient apiClient, String id, int numSteps) Increments an achievement by the given number of steps.
abstract PendingResult<Achievements.LoadAchievementsResult> | load(GoogleApiClient apiClient, boolean forceReload) Asynchronously load achievement data for the currently signed in player.
abstract void | reveal(GoogleApiClient apiClient, String id) Reveal a hidden achievement to the currently signed in player.
abstract PendingResult<Achievements.UpdateAchievementResult> | revealImmediate(GoogleApiClient apiClient, String id) Reveal a hidden achievement to the currently signed in player.
abstract void | setSteps(GoogleApiClient apiClient, String id, int numSteps) Set an achievement to have at least the given number of steps completed.
abstract PendingResult<Achievements.UpdateAchievementResult> | setStepsImmediate(GoogleApiClient apiClient, String id, int numSteps) Set an achievement to have at least the given number of steps completed.
abstract void | unlock(GoogleApiClient apiClient, String id) Unlock an achievement for the currently signed in player.
abstract PendingResult<Achievements.UpdateAchievementResult> | unlockImmediate(GoogleApiClient apiClient, String id) Unlock an achievement for the currently signed in player.

## Public Methods

#### public abstract Intent getAchievementsIntent (GoogleApiClient apiClient)

Gets an intent to show the list of achievements for a game. Note that this must be invoked with `startActivityForResult(Intent, int)`, so that the identity of the calling package can be established.

A `RESULT_RECONNECT_REQUIRED` may be returned as the resultCode in `onActivityResult(int, int, Intent)` if the GoogleApiClient ends up in an inconsistent state.

Required API: `API`
Required Scopes: `SCOPE_GAMES`

##### Parameters

apiClient | The `GoogleApiClient` to service the call.

##### Returns

- An `Intent` that can be started to view the currently signed in player's achievements.

#### public abstract void increment (GoogleApiClient apiClient, String id, int numSteps)

Increments an achievement by the given number of steps. The achievement must be an incremental achievement. Once an achievement reaches at least the maximum number of steps, it will be unlocked automatically. Any further increments will be ignored.

This is the fire-and-forget form of the API. Use this form if you don't need to know the status of the operation immediately. For most applications, this will be the preferred API to use, though note that the update may not be sent to the server until the next sync. See `incrementImmediate(GoogleApiClient, String, int)` if you need the operation to attempt to communicate to the server immediately or need to have the status code delivered to your application.

Required API: `API`
Required Scopes: `SCOPE_GAMES`

##### Parameters

apiClient | The `GoogleApiClient` to service the call.
id | The achievement ID to increment.
numSteps | The number of steps to increment by. Must be greater than 0.

#### public abstract PendingResult<Achievements.UpdateAchievementResult> incrementImmediate (GoogleApiClient apiClient, String id, int numSteps)

Increments an achievement by the given number of steps. The achievement must be an incremental achievement. Once an achievement reaches at least the maximum number of steps, it will be unlocked automatically. Any further increments will be ignored.

This form of the API will attempt to update the user's achievement on the server immediately, and will return a GamesPendingResult that can be used to retrieve the result.

Required API: `API`
Required Scopes: `SCOPE_GAMES`

##### Parameters

apiClient | The `GoogleApiClient` to service the call.
id | The ID of the achievement to increment.
numSteps | The number of steps to increment by. Must be greater than 0.

##### Returns

- `PendingResult` to access the data when available.

#### public abstract PendingResult<Achievements.LoadAchievementsResult> load (GoogleApiClient apiClient, boolean forceReload)

Asynchronously load achievement data for the currently signed in player.

Required API: `API`
Required Scopes: `SCOPE_GAMES`

##### Parameters

apiClient | The `GoogleApiClient` to service the call.
forceReload | If true, this call will clear any locally cached data and attempt to fetch the latest data from the server. This would commonly be used for something like a user-initiated refresh. Normally, this should be set to false to gain advantages of data caching.

##### Returns

- `PendingResult` to access the data when available.

#### public abstract void reveal (GoogleApiClient apiClient, String id)

Reveal a hidden achievement to the currently signed in player. If the achievement has already been unlocked, this will have no effect.

This is the fire-and-forget form of the API. Use this form if you don't need to know the status of the operation immediately. For most applications, this will be the preferred API to use, though note that the update may not be sent to the server until the next sync. See `revealImmediate(GoogleApiClient, String)` if you need the operation to attempt to communicate to the server immediately or need to have the status code delivered to your application.

Required API: `API`
Required Scopes: `SCOPE_GAMES`

##### Parameters

apiClient | The `GoogleApiClient` to service the call.
id | The achievement ID to reveal

##### See Also

- `unlock(GoogleApiClient, String)`

#### public abstract PendingResult<Achievements.UpdateAchievementResult> revealImmediate (GoogleApiClient apiClient, String id)

Reveal a hidden achievement to the currently signed in player. If the achievement is already visible, this will have no effect.

This form of the API will attempt to update the user's achievement on the server immediately, and will return a GamesPendingResult that can be used to retrieve the result.

Required API: `API`
Required Scopes: `SCOPE_GAMES`

##### Parameters

apiClient | The `GoogleApiClient` to service the call.
id | The ID of the achievement to reveal

##### Returns

- `PendingResult` to access the data when available.

##### See Also

- `unlockImmediate(GoogleApiClient, String)`

#### public abstract void setSteps (GoogleApiClient apiClient, String id, int numSteps)

Set an achievement to have at least the given number of steps completed. Calling this method while the achievement already has more steps than the provided value is a no-op. Once the achievement reaches the maximum number of steps, the achievement will automatically be unlocked, and any further mutation operations will be ignored.

This is the fire-and-forget form of the API. Use this form if you don't need to know the status of the operation immediately. For most applications, this will be the preferred API to use, though note that the update may not be sent to the server until the next sync. See `setStepsImmediate(GoogleApiClient, String, int)` if you need the operation to attempt to communicate to the server immediately or need to have the status code delivered to your application.

Required API: `API`
Required Scopes: `SCOPE_GAMES`

##### Parameters

apiClient | The `GoogleApiClient` to service the call.
id | The ID of the achievement to modify.
numSteps | The number of steps to set the achievement to. Must be greater than 0.

#### public abstract PendingResult<Achievements.UpdateAchievementResult> setStepsImmediate (GoogleApiClient apiClient, String id, int numSteps)

Set an achievement to have at least the given number of steps completed. Calling this method while the achievement already has more steps than the provided value is a no-op. Once the achievement reaches the maximum number of steps, the achievement will automatically be unlocked, and any further mutation operations will be ignored.

This form of the API will attempt to update the user's achievement on the server immediately, and will return a GamesPendingResult that can be used to retrieve the result.

Required API: `API`
Required Scopes: `SCOPE_GAMES`

##### Parameters

apiClient | The `GoogleApiClient` to service the call.
id | The ID of the achievement to modify.
numSteps | The number of steps to set the achievement to. Must be greater than 0.

##### Returns

- `PendingResult` to access the data when available.

#### public abstract void unlock (GoogleApiClient apiClient, String id)

Unlock an achievement for the currently signed in player. If the achievement is hidden this will reveal it to the player.

This is the fire-and-forget form of the API. Use this form if you don't need to know the status of the operation immediately. For most applications, this will be the preferred API to use, though note that the update may not be sent to the server until the next sync. See `unlockImmediate(GoogleApiClient, String)` if you need the operation to attempt to communicate to the server immediately or need to have the status code delivered to your application.

Required API: `API`
Required Scopes: `SCOPE_GAMES`

##### Parameters

apiClient | The `GoogleApiClient` to service the call.
id | The achievement ID to unlock

##### See Also

- `reveal(GoogleApiClient, String)`

#### public abstract PendingResult<Achievements.UpdateAchievementResult> unlockImmediate (GoogleApiClient apiClient, String id)

Unlock an achievement for the currently signed in player. If the achievement is hidden this will reveal it to the player.

This form of the API will attempt to update the user's achievement on the server immediately, and will return a GamesPendingResult that can be used to retrieve the result.

Required API: `API`
Required Scopes: `SCOPE_GAMES`

##### Parameters

apiClient | The `GoogleApiClient` to service the call.
id | The ID of the achievement to unlock.

##### Returns

- `PendingResult` to access the data when available.

##### See Also

- `revealImmediate(GoogleApiClient, String)`