Game Mode API

The Game Mode API allows you to optimize your game for the best performance or longest battery life when the user selects the corresponding game mode.

Alternatively, you can submit requests for Game Mode interventions to improve the performance of games that are no longer being updated by developers.

The Game Mode API and interventions are available on select Android 12 devices.

Setup

To use the Game Mode API in your game, do the following:

  1. Download and install the Android 12 Preview SDK.

  2. In the AndroidManifest.xml file, declare your app as a game by setting the appCategory attribute in the <application> element:

android:appCategory="game"
  1. Query the current game mode by adding this to your main activity:

Java

// Only call this for Android 12 devices
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.S ) {
  // Get GameManager from SystemService
  GameManager gameManager = Context.getSystemService(GameManager.class);

  // Returns the selected GameMode
  int gameMode = gameManager.getGameMode();
}

Kotlin

// Only call this for Android 12 devices
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
  // Get GameManager from SystemService
  val gameManager: GameManager? = context.getSystemService(Context.GAME_SERVICE) as GameManager?

  // Returns the selected GameMode
  val gameMode = gameManager?.gameMode
}
Supported game mode Description
UNSUPPORTED The game does not declare support for the Game Mode API and it does not support Game Mode interventions.
STANDARD The user has not selected a game mode or the user selected standard mode.
PERFORMANCE Provides the lowest latency frame rates in exchange for reduced battery life and fidelity.
BATTERY Provides the longest possible battery life in exchange for reduced fidelity or frame rates.
  1. Add code to query the game mode state in the onResume function:

    Example with user setting Battery mode

Best Practices

If your game already supports multiple fidelity and frame rate targets, you should identify the appropriate settings for performance and battery saver modes:

  • To consistently achieve the maximum device frame rates: consider slight reductions in fidelity to achieve higher frame rates.

  • To improve battery life: consider choosing a lower display refresh rate (e.g. 30Hz or 60Hz) and use frame pacing to target the reduced rate.

For high-fidelity games such as first-person shooters, multiplayer online battle arenas (MOBAs), and role-playing games (RPGs), you should focus on achieving high consistent frame rates to maximize user immersion.

For both high-fidelity and casual games, you should support battery saver mode to lengthen playtime by reducing your peak frame rates.

Testing

Try out the new game behavior by setting the game mode status via adb:

adb shell cmd game mode [standard|performance|battery] <PACKAGE_NAME>

Publishing

To enable the Game Mode UI, add the following to the <application> element in your AndroidManifest.xml file.

<application>
  <!-- default is false -->
  <meta-data
        android:name="com.android.app.gamemode.performance.enabled"
        android:value="true"/>

  <!-- default is false -->
  <meta-data
        android:name="com.android.app.gamemode.battery.enabled"
        android:value="true"/>
  ...
</application>

Next

Read Game Mode interventions to improve a game's performance when it isn't possible to provide game updates.