只要使用 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);}