تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
بعد إيقاف واجهة برمجة التطبيقات
Google Sign-In API
نهائيًا، سنزيل حزمة تطوير البرامج (SDK) لألعاب الإصدار 1 في عام 2026. بعد شباط (فبراير) 2025، لن تتمكّن من نشر
العناوين التي تم دمجها حديثًا مع حزمة تطوير البرامج (SDK) لإصدار 1 من "ألعاب Google Play" على Google Play. ننصحك باستخدام
حزمة تطوير البرامج (SDK) لإصدار 2 من "ألعاب Google Play" بدلاً من ذلك.
على الرغم من أنّ العناوين الحالية التي تم دمجها مع الإصدار 1 من الألعاب السابقة ستظل تعمل لعدة
سنوات، ننصحك بنقل بياناتها إلى الإصدار 2
اعتبارًا من حزيران (يونيو) 2025.
يتناول هذا الدليل استخدام حزمة تطوير البرامج (SDK) لإصدار 1 من "خدمات ألعاب Play". للحصول على معلومات
عن أحدث إصدار من حزمة SDK، يُرجى الاطّلاع على
مستندات الإصدار 2.
يوضّح لك هذا الدليل كيفية جمع بيانات أسلوب اللعب لدى اللاعبين لأغراض إحصاءات الألعاب باستخدام واجهات برمجة تطبيقات الأحداث
التي تقدّمها "خدمات ألعاب Play". يمكن العثور على واجهات برمجة التطبيقات في
com.google.android.gms.games.event
وcom.google.android.gms.games.
يمكنك إضافة رمز في لعبتك لإرسال إشعار إلى "خدمات ألعاب Google Play" عند حدوث
حدث يهمّ لعبتك.
لإرسال تعديل حدث، يمكنك استدعاء EventsClient.increment() باستخدام القيمة eventId وأحد الأرقام الكاملة incrementAmount التي تساوي 0 أو أكبر.
تنشئ "خدمات ألعاب Google Play" القيمة eventId عند تحديد الحدث في Google Play Console لأول مرة، ويتم استخدامها لتحديد هذا الحدث بشكل فريد في
لعبتك.
يمكنك استخدام الإدخال incrementAmount لتحديد مستوى تقدّم اللاعب الكمي نحو
إكمال بعض الأهداف المتعلّقة باللعبة. على سبيل المثال، إذا كان الحدث الذي تريد
لعبتك تتبُّعه هو "هزيمة 500 وحش ذي عيون حشرات"، يمكن أن تكون قيمة incrementAmount هي
عدد الوحوش التي قتلها اللاعب في معركة واحدة.
في ما يلي مثال على كيفية إرسال حدث بقيمة متزايدة تبلغ 1:
public void submitEvent(String eventId) {
Games.getEventsClient(this, GoogleSignIn.getLastSignedInAccount(this))
.increment(eventId, 1);
}
استرداد الأحداث
يمكنك استرداد جميع بيانات الأحداث المخزّنة في خوادم Google للعبة من خلال
طلب EventsClient.load(). في دعوة الأسلوب، أدخِل قيمة منطقية للإشارة إلى ما إذا كان يجب على "خدمات ألعاب Google Play" محو البيانات التي تم تخزينها مؤقتًا في ذاكرة التخزين المؤقت على جهاز المستخدم.
لاسترداد بيانات عن أحداث معيّنة حدّدتها في Google Play Console، يمكنك استدعاء دالة
EventsClient.loadByIds() وإدخال صفيف من أرقام تعريف الأحداث في مَعلمات الإدخال.
يوضّح المقتطف التالي كيفية طلب ข้อมูล من "خدمات ألعاب Google Play" للحصول على
قائمة بجميع أحداث لعبتك:
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-27 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Events in Android games\n\nFollowing the deprecation of the\n[Google Sign-In](https://android-developers.googleblog.com/2024/09/streamlining-android-authentication-credential-manager-replaces-legacy-apis.html)\nAPI, we are removing the games v1 SDK in 2026. After February 2025, you will be unable to publish\ntitles that are newly integrated with games v1 SDK, on Google Play. We recommend that you use the\ngames v2 SDK instead. \n\nWhile existing titles with the previous games v1 integrations continue to function for a\ncouple of years, you are encouraged to\n[migrate to v2](/games/pgs/android/migrate-to-v2)\nstarting June 2025. \n\nThis guide is for using the Play Games Services v1 SDK. For information\non the latest SDK version, see the\n[v2 documentation](/games/pgs/android/events).\n\nThis guide shows you how to collect player gameplay data for game analytics using the events APIs\nprovided by Google Play Games Services. The APIs can be found in the\n[`com.google.android.gms.games.event`](https://developers.google.com/android/reference/com/google/android/gms/games/event/package-summary)\nand [`com.google.android.gms.games`](https://developers.google.com/android/reference/com/google/android/gms/games/package-summary).\n\nBefore you begin\n----------------\n\nIf you haven't already done so, you might find it helpful to review the\n[events game concepts](/games/pgs/events).\n\nBefore you start to code using the events APIs:\n\n- Define the events for your game in the [Google Play Console](https://play.google.com/apps/publish/).\n- Follow the [sign-in checklist recommendations](/games/pgs/v1/quality#sign-in).\n\nGet the events client\n---------------------\n\nTo start using the events APIs, your game must first obtain an\n[`EventsClient`](https://developers.google.com/android/reference/com/google/android/gms/games/EventsClient) object. You can do this by calling the\n[`Games.getEventsClient()`](https://developers.google.com/android/reference/com/google/android/gms/games/Games.html#getEventsClient(android.app.Activity,%20com.google.android.gms.auth.api.signin.GoogleSignInAccount)) method and passing in the\nactivity and the [`GoogleSignInAccount`](https://developers.google.com/android/reference/com/google/android/gms/auth/api/signin/GoogleSignInAccount) for the current player. To learn how to\nretrieve the player account information, see\n[Sign-in in Android Games](/games/pgs/v1/android/signin).\n| **Note:** The [`EventsClient`](https://developers.google.com/android/reference/com/google/android/gms/games/EventsClient) class makes use of the Google Play services [`Task`](https://developers.google.com/android/reference/com/google/android/gms/tasks/Task) class to return results asynchronously. To learn more about using tasks to manage threaded work, see the [Tasks API developer guide](https://developers.google.com/android/guides/tasks).\n\nSubmit events\n-------------\n\nYou can add code in your game to notify Google Play Games Services whenever an\nevent of interest to your game occurs.\n\nTo send an event update, call [`EventsClient.increment()`](https://developers.google.com/android/reference/com/google/android/gms/games/EventsClient.html#increment(java.lang.String,%20int)) with the `eventId` value and an\ninteger `incrementAmount` that is equal to or greater than 0.\n\n- The `eventId` is generated by Google Play Games Services when you first define the event in the Google Play Console and is used to uniquely identify this event in your game.\n- You can use the `incrementAmount` input to specify the player's quantitative progress towards completing some game-specific goal. For example, if the event your game wants to track is *'Defeat 500 bug-eyed monsters'* , the `incrementAmount` value can be the number of monsters that the player killed in a single battle.\n\nHere's an example of how to submit an event with an increment amount of 1: \n\n```text\npublic void submitEvent(String eventId) {\n Games.getEventsClient(this, GoogleSignIn.getLastSignedInAccount(this))\n .increment(eventId, 1);\n}\n```\n\nRetrieve events\n---------------\n\nYou can retrieve all events data stored in Google's servers for your game, by\ncalling [`EventsClient.load()`](https://developers.google.com/android/reference/com/google/android/gms/games/EventsClient.html#load(boolean)). In the\nmethod call, pass in a boolean value to indicate if Google Play Games Services should clear the locally\ncached data on the user's device.\n\nTo retrieve data for specific events that you defined in the Google Play Console, call\n[`EventsClient.loadByIds()`](https://developers.google.com/android/reference/com/google/android/gms/games/EventsClient.html#loadByIds(boolean,%20java.lang.String...)) and pass in an array of event IDs in the input parameters.\n\nThe following snippet shows how you can query Google Play Games Services for the\nlist of all events for your game: \n\n```gdscript\npublic void loadEvents() {\n Games.getEventsClient(this, GoogleSignIn.getLastSignedInAccount(this))\n .load(true)\n .addOnCompleteListener(new OnCompleteListener\u003cAnnotatedData\u003cEventBuffer\u003e\u003e() {\n @Override\n public void onComplete(@NonNull Task\u003cAnnotatedData\u003cEventBuffer\u003e\u003e task) {\n if (task.isSuccessful()) {\n // Process all the events.\n for (Event event : task.getResult().get()) {\n Log.d(TAG, \"loaded event \" + event.getName());\n }\n } else {\n // Handle Error\n Exception exception = task.getException();\n int statusCode = CommonStatusCodes.DEVELOPER_ERROR;\n if (exception instanceof ApiException) {\n ApiException apiException = (ApiException) exception;\n statusCode = apiException.getStatusCode();\n }\n showError(statusCode);\n }\n }\n });\n}\n```"]]