সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
এই নির্দেশিকা আপনাকে দেখায় কিভাবে Google Play Games পরিষেবার দ্বারা প্রদত্ত ইভেন্ট API ব্যবহার করে গেম বিশ্লেষণের জন্য প্লেয়ার গেমপ্লে ডেটা সংগ্রহ করতে হয়। APIগুলি com.google.android.gms.games.event এবং com.google.android.gms.games প্যাকেজে পাওয়া যাবে৷
ইভেন্ট API ব্যবহার শুরু করতে, আপনার গেমটিকে প্রথমে একটি EventsClient অবজেক্ট পেতে হবে। আপনি PlayGames.getEventsClient() পদ্ধতিতে কল করে এবং কার্যকলাপে পাস করে এটি করতে পারেন।
ঘটনা জমা দিন
যখনই আপনার গেমে আগ্রহের ঘটনা ঘটবে তখনই আপনি প্লে গেম পরিষেবাগুলিকে অবহিত করতে আপনার গেমটিতে কোড যোগ করতে পারেন।
একটি ইভেন্ট আপডেট পাঠাতে, EventsClient.increment() কল করুন eventId মান এবং একটি পূর্ণসংখ্যা incrementAmount যা 0 এর সমান বা তার বেশি।
যখন আপনি Google Play Console-এ ইভেন্টটি প্রথম সংজ্ঞায়িত করেন তখন Play Games পরিষেবা দ্বারা eventId তৈরি হয় এবং আপনার গেমে এই ইভেন্টটিকে অনন্যভাবে শনাক্ত করতে ব্যবহৃত হয়।
আপনি কিছু গেম-নির্দিষ্ট লক্ষ্য পূরণের দিকে খেলোয়াড়ের পরিমাণগত অগ্রগতি নির্দিষ্ট করতে incrementAmount ইনপুট ব্যবহার করতে পারেন। উদাহরণ স্বরূপ, যদি আপনার গেমটি যে ইভেন্টটি ট্র্যাক করতে চায় সেটি হল 'Defeat 500 bug-eyed Monsters' , তাহলে incrementAmount মান হতে পারে সেই দানবের সংখ্যা যা প্লেয়ার একটি একক যুদ্ধে মেরেছে।
1 বৃদ্ধির পরিমাণ সহ একটি ইভেন্ট কীভাবে জমা দিতে হয় তার একটি উদাহরণ এখানে রয়েছে:
public void submitEvent(String eventId) {
PlayGames.getEventsClient(this)
.increment(eventId, 1);
}
ঘটনা পুনরুদ্ধার
আপনি EventsClient.load() কল করে আপনার গেমের জন্য Google এর সার্ভারে সংরক্ষিত সমস্ত ইভেন্ট ডেটা পুনরুদ্ধার করতে পারেন। মেথড কলে, প্লে গেম পরিষেবাগুলি ব্যবহারকারীর ডিভাইসে স্থানীয়ভাবে ক্যাশে করা ডেটা সাফ করবে কিনা তা নির্দেশ করতে একটি বুলিয়ান মান পাস করুন৷
আপনি Google Play Console-এ সংজ্ঞায়িত নির্দিষ্ট ইভেন্টগুলির ডেটা পুনরুদ্ধার করতে, EventsClient.loadByIds() কল করুন এবং ইনপুট প্যারামিটারে ইভেন্ট আইডিগুলির একটি অ্যারেতে পাস করুন৷
নিম্নলিখিত স্নিপেটটি দেখায় যে আপনি কীভাবে আপনার গেমের সমস্ত ইভেন্টের তালিকার জন্য প্লে গেম পরিষেবাগুলিকে জিজ্ঞাসা করতে পারেন:
এই পৃষ্ঠার কন্টেন্ট ও কোডের নমুনাগুলি Content License-এ বর্ণিত লাইসেন্সের অধীনস্থ। Java এবং OpenJDK হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-07-29 UTC-তে শেষবার আপডেট করা হয়েছে।
[[["সহজে বোঝা যায়","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-29 UTC-তে শেষবার আপডেট করা হয়েছে।"],[],[],null,["# Events for Android games\n\n| **Note:** This guide is for the Play Games Services v2 SDK. For information on the previous version of this SDK, see the [Play Games Services v1\n| documentation](/games/pgs/v1/android/events).\n\nThis guide shows you how to collect player gameplay data for game analytics\nusing the events APIs provided 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)\npackages.\n\nBefore you begin\n----------------\n\nIf you haven't already done so, you might find it helpful to review the [events\ngame concepts](/games/pgs/events).\n\nBefore you start to code using the events APIs:\n\n- Define the events for your game in the\n [Google Play Console](https://play.google.com/apps/publish/).\n\n- Follow the [sign-in checklist recommendations](/games/pgs/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)\nobject. You can do this by calling the [`PlayGames.getEventsClient()`](https://developers.google.com/android/reference/com/google/android/gms/games/PlayGames#public-static-eventsclient-geteventsclient-activity-activity)\nmethod and passing in the activity.\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\n| guide](https://developers.google.com/android/guides/tasks).\n\nSubmit events\n-------------\n\nYou can add code in your game to notify Play Games Services whenever an event of\ninterest to your game occurs.\n\nTo send an event update, call\n[`EventsClient.increment()`](https://developers.google.com/android/reference/com/google/android/gms/games/EventsClient#increment)\nwith the `eventId` value and an integer `incrementAmount` that is equal to or\ngreater than 0.\n\n- The `eventId` is generated by Play Games Services when you first define the\n event in the Google Play Console and is used to uniquely identify this\n event in your game.\n\n- You can use the `incrementAmount` input to specify the player's quantitative\n progress towards completing some game-specific goal. For example, if the\n event your game wants to track is *'Defeat 500 bug-eyed monsters'* , the\n `incrementAmount` value can be the number of monsters that the player killed\n 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 PlayGames.getEventsClient(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\n[`EventsClient.load()`](https://developers.google.com/android/reference/com/google/android/gms/games/EventsClient#load(boolean)).\nIn the method call, pass in a boolean value to indicate if Play Games Services\nshould clear the locally cached data on the user's device.\n\nTo retrieve data for specific events that you defined in the\nGoogle Play Console, call\n[`EventsClient.loadByIds()`](https://developers.google.com/android/reference/com/google/android/gms/games/EventsClient#loadByIds)\nand pass in an array of event IDs in the input parameters.\n\nThe following snippet shows how you can query Play Games Services for the list of\nall events for your game: \n\n```gdscript\npublic void loadEvents() {\n PlayGames.getEventsClient(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```"]]