Stay organized with collections
Save and categorize content based on your preferences.
GameManager
class GameManager
The GameManager allows system apps to modify and query the game mode of apps.
Note: After 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:
Therefore, you should always do a null
check on the return value of Context.getSystemService(Class)
and Context.getSystemService(String)
when trying to obtain an instance of GameManager on the aforementioned device types.
Summary
Constants |
static Int |
Battery game mode will save battery and give longer game play time.
|
static Int |
Custom game mode that has user-provided configuration overrides.
|
static Int |
Performance game mode maximizes the game's performance.
|
static Int |
Standard game mode means the platform will use the game's default performance characteristics.
|
static Int |
Game mode is not supported for this application.
|
Public methods |
Int |
Return the user selected game mode for this application.
|
Unit |
Called by games to communicate the current state to the platform.
|
Constants
GAME_MODE_BATTERY
static val GAME_MODE_BATTERY: Int
Battery game mode will save battery and give longer game play time.
Value: 3
GAME_MODE_CUSTOM
static val GAME_MODE_CUSTOM: Int
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.
Value: 4
static val GAME_MODE_PERFORMANCE: Int
Performance game mode maximizes the game's performance.
This game mode is highly likely to increase battery consumption.
Value: 2
GAME_MODE_STANDARD
static val GAME_MODE_STANDARD: Int
Standard game mode means the platform will use the game's default performance characteristics.
Value: 1
GAME_MODE_UNSUPPORTED
static val GAME_MODE_UNSUPPORTED: Int
Game mode is not supported for this application.
Value: 0
Public methods
setGameState
fun setGameState(gameState: GameState): Unit
Called by games to communicate the current state to the platform.
Parameters |
gameState |
GameState: An object set to the current state. This value cannot be null . |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 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-02-10 UTC."],[],[],null,["# GameManager\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nGameManager\n===========\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/app/GameManager \"View this page in Java\") \n\n```\nclass GameManager\n```\n\n|---|------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.app.GameManager](#) |\n\nThe GameManager allows system apps to modify and query the game mode of apps.\n\n**Note:** After [android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM](../os/Build.VERSION_CODES.html#VANILLA_ICE_CREAM:kotlin.Int), some devices that do not support the GameManager features *may* not publish a GameManager instance. These device types include:\n\n- Wear devices ([PackageManager.FEATURE_WATCH](../content/pm/PackageManager.html#FEATURE_WATCH:kotlin.String))\n\nTherefore, you should always do a `null` check on the return value of [Context.getSystemService(Class)](../content/Context.html#getSystemService(java.lang.Class)) and [Context.getSystemService(String)](../content/Context.html#getSystemService(kotlin.String)) when trying to obtain an instance of GameManager on the aforementioned device types.\n\nSummary\n-------\n\n| Constants ||\n|-----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [GAME_MODE_BATTERY](#GAME_MODE_BATTERY:kotlin.Int) Battery game mode will save battery and give longer game play time. |\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [GAME_MODE_CUSTOM](#GAME_MODE_CUSTOM:kotlin.Int) Custom game mode that has user-provided configuration overrides. |\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [GAME_MODE_PERFORMANCE](#GAME_MODE_PERFORMANCE:kotlin.Int) Performance game mode maximizes the game's performance. |\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [GAME_MODE_STANDARD](#GAME_MODE_STANDARD:kotlin.Int) Standard game mode means the platform will use the game's default performance characteristics. |\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [GAME_MODE_UNSUPPORTED](#GAME_MODE_UNSUPPORTED:kotlin.Int) Game mode is not supported for this application. |\n\n| Public methods ||\n|------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [getGameMode](#getGameMode())`()` Return the user selected game mode for this application. |\n| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [setGameState](#setGameState(android.app.GameState))`(`gameState:` `[GameState](/reference/kotlin/android/app/GameState)`)` Called by games to communicate the current state to the platform. |\n\nConstants\n---------\n\n### GAME_MODE_BATTERY\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val GAME_MODE_BATTERY: Int\n```\n\nBattery game mode will save battery and give longer game play time. \n\n Value: 3\n\n### GAME_MODE_CUSTOM\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val GAME_MODE_CUSTOM: Int\n```\n\nCustom game mode that has user-provided configuration overrides.\n\nCustom 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. \n\n Value: 4\n\n### GAME_MODE_PERFORMANCE\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val GAME_MODE_PERFORMANCE: Int\n```\n\nPerformance game mode maximizes the game's performance.\n\nThis game mode is highly likely to increase battery consumption. \n\n Value: 2\n\n### GAME_MODE_STANDARD\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val GAME_MODE_STANDARD: Int\n```\n\nStandard game mode means the platform will use the game's default performance characteristics. \n\n Value: 1\n\n### GAME_MODE_UNSUPPORTED\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val GAME_MODE_UNSUPPORTED: Int\n```\n\nGame mode is not supported for this application. \n\n Value: 0\n\nPublic methods\n--------------\n\n### getGameMode\n\nAdded in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getGameMode(): Int\n```\n\nReturn the user selected game mode for this application.\n\nAn 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 [GAME_MODE_UNSUPPORTED](#GAME_MODE_UNSUPPORTED:kotlin.Int).\n\nDevelopers should call this API every time the application is resumed.\n\nIf a game's `targetSdkVersion` is [android.os.Build.VERSION_CODES#TIRAMISU](../os/Build.VERSION_CODES.html#TIRAMISU:kotlin.Int) or lower, and when the game mode is set to [GAME_MODE_CUSTOM](#GAME_MODE_CUSTOM:kotlin.Int) which is available in [android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE](../os/Build.VERSION_CODES.html#UPSIDE_DOWN_CAKE:kotlin.Int) or newer, this API will return [GAME_MODE_STANDARD](#GAME_MODE_STANDARD:kotlin.Int) instead for backward compatibility.\n\n| Return ||\n|----------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | Value is [android.app.GameManager#GAME_MODE_UNSUPPORTED](#GAME_MODE_UNSUPPORTED:kotlin.Int), [android.app.GameManager#GAME_MODE_STANDARD](#GAME_MODE_STANDARD:kotlin.Int), [android.app.GameManager#GAME_MODE_PERFORMANCE](#GAME_MODE_PERFORMANCE:kotlin.Int), [android.app.GameManager#GAME_MODE_BATTERY](#GAME_MODE_BATTERY:kotlin.Int), or [android.app.GameManager#GAME_MODE_CUSTOM](#GAME_MODE_CUSTOM:kotlin.Int) |\n\n### setGameState\n\nAdded in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun setGameState(gameState: GameState): Unit\n```\n\nCalled by games to communicate the current state to the platform.\n\n| Parameters ||\n|-------------|------------------------------------------------------------------------------------------------------------------------|\n| `gameState` | [GameState](/reference/kotlin/android/app/GameState): An object set to the current state. This value cannot be `null`. |"]]