Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/app/GameManager#constants) \| [Methods](https://developer.android.com/reference/android/app/GameManager#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/app/GameManager#inhmethods)

# GameManager

*** ** * ** ***

` public final class GameManager `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.app.GameManager |

<br />

*** ** * ** ***

The GameManager allows system apps to modify and query the game mode of apps.

**Note:** After `https://developer.android.com/reference/android/os/Build.VERSION_CODES#VANILLA_ICE_CREAM`, some devices that do not support the GameManager features *may* not publish a GameManager instance. These device types include:

- Wear devices (`https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_WATCH`)

Therefore, you should always do a `null` check on the return value of `https://developer.android.com/reference/android/content/Context#getSystemService(java.lang.Class<T>)` and `https://developer.android.com/reference/android/content/Context#getSystemService(java.lang.String)` when trying to obtain an instance of GameManager on the aforementioned device types.

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/app/GameManager#GAME_MODE_BATTERY` Battery game mode will save battery and give longer game play time. |
| `int` | `https://developer.android.com/reference/android/app/GameManager#GAME_MODE_CUSTOM` Custom game mode that has user-provided configuration overrides. |
| `int` | `https://developer.android.com/reference/android/app/GameManager#GAME_MODE_PERFORMANCE` Performance game mode maximizes the game's performance. |
| `int` | `https://developer.android.com/reference/android/app/GameManager#GAME_MODE_STANDARD` Standard game mode means the platform will use the game's default performance characteristics. |
| `int` | `https://developer.android.com/reference/android/app/GameManager#GAME_MODE_UNSUPPORTED` Game mode is not supported for this application. |

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/android/app/GameManager#getGameMode()() ` Return the user selected game mode for this application. |
| ` void` | ` https://developer.android.com/reference/android/app/GameManager#setGameState(android.app.GameState)(https://developer.android.com/reference/android/app/GameState gameState) ` Called by games to communicate the current state to the platform. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Constants

### GAME_MODE_BATTERY

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int GAME_MODE_BATTERY
```

Battery game mode will save battery and give longer game play time.

<br />

Constant Value: 3 (0x00000003)

### GAME_MODE_CUSTOM

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int GAME_MODE_CUSTOM
```

Custom game mode that has user-provided configuration overrides.

Custom game mode is expected to be handled only by the platform using users' preferred config. It is currently not allowed to opt in custom mode in game mode XML file nor expected to perform app-based optimizations when activated.

<br />

Constant Value: 4 (0x00000004)

### GAME_MODE_PERFORMANCE

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int GAME_MODE_PERFORMANCE
```

Performance game mode maximizes the game's performance.

This game mode is highly likely to increase battery consumption.

<br />

Constant Value: 2 (0x00000002)

### GAME_MODE_STANDARD

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int GAME_MODE_STANDARD
```

Standard game mode means the platform will use the game's default performance characteristics.

<br />

Constant Value: 1 (0x00000001)

### GAME_MODE_UNSUPPORTED

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int GAME_MODE_UNSUPPORTED
```

Game mode is not supported for this application.

<br />

Constant Value: 0 (0x00000000)

## Public methods

### getGameMode

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getGameMode ()
```

Return the user selected game mode for this application.

An application can use `android:isGame="true"` or `android:appCategory="game"` to indicate that the application is a game. If an application is not a game, always return `https://developer.android.com/reference/android/app/GameManager#GAME_MODE_UNSUPPORTED`.

Developers should call this API every time the application is resumed.

If a game's `targetSdkVersion` is `https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU` or lower, and when the game mode is set to `https://developer.android.com/reference/android/app/GameManager#GAME_MODE_CUSTOM` which is available in `https://developer.android.com/reference/android/os/Build.VERSION_CODES#UPSIDE_DOWN_CAKE` or newer, this API will return `https://developer.android.com/reference/android/app/GameManager#GAME_MODE_STANDARD` instead for backward compatibility.

<br />

| Returns ||
|---|---|
| `int` | Value is one of the following: - `https://developer.android.com/reference/android/app/GameManager#GAME_MODE_UNSUPPORTED` - `https://developer.android.com/reference/android/app/GameManager#GAME_MODE_STANDARD` - `https://developer.android.com/reference/android/app/GameManager#GAME_MODE_PERFORMANCE` - `https://developer.android.com/reference/android/app/GameManager#GAME_MODE_BATTERY` - `https://developer.android.com/reference/android/app/GameManager#GAME_MODE_CUSTOM` |

### setGameState

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setGameState (GameState gameState)
```

Called by games to communicate the current state to the platform.

<br />

| Parameters ||
|---|---|
| `gameState` | `GameState`: An object set to the current state. This value cannot be `null`. <br /> |