Game State API を使用すると、現在のゲームの状態をシステムに知らせることができます
負荷の高いネットワーク ゲームプレイ、レンダリング アクティビティ、
ゲーム内メニュー、広告の表示など)。この貴重な情報を使って、システムは
それに応じてリソースと電力を最適化できます
Java
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.S){// Get GameManager from SystemServiceGameManagergameManager=Context.getSystemService(GameManager.class);GameStategameState=newGameState(false,GameState.MODE_GAMEPLAY_UNINTERRUPTIBLE);gameManager.setGameState(gameState);}
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-26 UTC。"],[],[],null,["# Game State API\n\n**Released**:\n\nAndroid 13 (API Level 33) - [Java](/reference/android/app/GameState)\n\nWith Game State API, you can let the system know what the game is currently\ndoing (for example: loading levels, intense networked gameplay, rendering\nin-game menu, showing ads, etc). With this valuable information, the system is\nbe able to optimize resources and power accordingly. \n\n### Java\n\n if ( Build.VERSION.SDK_INT \u003e= Build.VERSION_CODES.S ) {\n // Get GameManager from SystemService\n GameManager gameManager =\n Context.getSystemService(GameManager.class);\n GameState gameState = new GameState(false,\n GameState.MODE_GAMEPLAY_UNINTERRUPTIBLE);\n gameManager.setGameState(gameState);\n }\n\nCheck out the modes you can notify the system in the documentation\n[Summary](/reference/android/app/GameState#summary).\nIt is possible that the list will grow when different resource consumption\npatterns is discovered in the future."]]