باستخدام 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);}
اطّلِع على الأوضاع التي يمكنك إبلاغ النظام بها من خلال المستندات.
ملخّص:
ومن الممكن أن تزيد القائمة عند استهلاك موارد مختلفة
أنماط جديدة في المستقبل.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],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."]]