সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
এই দস্তাবেজটি ব্যাখ্যা করে যে কীভাবে অ্যান্ড্রয়েডে সচেতনতা API দিয়ে বিকাশ শুরু করবেন। সচেতনতা API হল Google Play পরিষেবার অংশ৷
সচেতনতা API ব্যবহার করতে, আপনার একটি Google অ্যাকাউন্ট প্রয়োজন। আপনার যদি ইতিমধ্যেই একটি অ্যাকাউন্ট থাকে, তাহলে আপনি প্রস্তুত। আপনি পরীক্ষার উদ্দেশ্যে একটি পৃথক Google অ্যাকাউন্টও চাইতে পারেন।
আপনি শুরু করার আগে
একটি API কী পান
আপনি যদি ইতিমধ্যে সচেতনতা API সক্ষম না করে থাকেন এবং একটি Google API কী প্রাপ্ত না করে থাকেন, তাহলে সাইনআপ এবং API কীগুলির ধাপগুলি অনুসরণ করুন।
আপনার অ্যাপ কনফিগার করুন
আপনার প্রকল্প-স্তরের build.gradle ফাইলে, আপনার buildscript এবং allprojects উভয় বিভাগেই Google এর Maven সংগ্রহস্থল অন্তর্ভুক্ত করুন:
আপনার অ্যাপের AndroidManifest.xml ফাইলে আপনার সচেতনতা API কী যোগ করুন। এটি করতে, android:name="com.google.android.awareness.API_KEY" এর সাথে একটি <meta-data> ট্যাগ যোগ করুন। android:value এর জন্য উদ্ধৃতি চিহ্ন দ্বারা বেষ্টিত আপনার নিজস্ব সচেতনতা API কী সন্নিবেশ করান।
আপনার অ্যাপের AndroidManifest.xml ফাইলে প্রয়োজনীয় অনুমতি যোগ করুন। আপনার অ্যাপ ব্যবহার করে API পদ্ধতি এবং বেড়ার প্রকারের উপর নির্ভর করে প্রয়োজনীয় অনুমতিগুলি পরিবর্তিত হয়।
উদাহরণ কল
getDetectedActivity() -এ নিম্নলিখিত উদাহরণ কলটি প্রদর্শন করে যে কীভাবে সচেতনতা API-এর সাথে সংযোগহীন Google Play পরিষেবা মডেল ব্যবহার করতে হয়:
// Each type of contextual information in the snapshot API has a corresponding "get" method.// For instance, this is how to get the user's current Activity.Awareness.getSnapshotClient(this).getDetectedActivity().addOnSuccessListener(newOnSuccessListener<DetectedActivityResponse>(){@OverridepublicvoidonSuccess(DetectedActivityResponsedar){ActivityRecognitionResultarr=dar.getActivityRecognitionResult();// getMostProbableActivity() is good enough for basic Activity detection.// To work within a threshold of confidence,// use ActivityRecognitionResult.getProbableActivities() to get a list of// potential current activities, and check the confidence of each one.DetectedActivityprobableActivity=arr.getMostProbableActivity();intconfidence=probableActivity.getConfidence();StringactivityStr=probableActivity.toString();mLogFragment.getLogView().println("Activity: "+activityStr+", Confidence: "+confidence+"/100");}})
পরবর্তী পদক্ষেপ
সচেতনতা API-এর মধ্যে বিভিন্ন API সম্পর্কে আরও জানুন:
[[["সহজে বোঝা যায়","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-09-04 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003eThis documentation provides a guide on how to start developing with the Awareness API on Android, which is part of Google Play services and requires a Google Account.\u003c/p\u003e\n"],["\u003cp\u003eBefore starting, developers need to obtain an API key, configure their app by adding necessary dependencies and permissions in the \u003ccode\u003ebuild.gradle\u003c/code\u003e and \u003ccode\u003eAndroidManifest.xml\u003c/code\u003e files, respectively, and include their API key in the manifest.\u003c/p\u003e\n"],["\u003cp\u003eAn example call demonstrates using the connectionless Google Play services model with the Awareness API, specifically showing how to get the user's current activity using the \u003ccode\u003egetDetectedActivity()\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can further explore the Awareness API through the Snapshot API and Fence API guides and references for more advanced functionalities.\u003c/p\u003e\n"]]],["To begin using the Awareness API, obtain a Google API key and configure your Android app. This involves adding Google's Maven repository to your project's `build.gradle` file and including the Awareness API dependency in your module's `build.gradle`. Insert your API key into `AndroidManifest.xml` and add necessary permissions, depending on the API methods used. The `getDetectedActivity()` example shows how to retrieve the user's current activity.\n"],null,["# Get started\n\nThis document explains how to start to develop with the Awareness API on\nAndroid. The Awareness API is part of [Google Play services](/android/guides/overview).\n\nTo use the Awareness API, you need a [Google Account](//www.google.com/accounts/NewAccount).\nIf you already have an account, then you're all set. You might also want a\nseparate Google Account for testing purposes.\n\nBefore you begin\n----------------\n\n### Obtain an API key\n\nIf you haven't already enabled the Awareness API and obtained a Google API key,\nfollow the steps in [Signup and API keys](/awareness/android-api/get-a-key)\nto do so.\n\n### Configure your app\n\n1. In your project-level `build.gradle` file, include Google's Maven repository\n in both your `buildscript` and `allprojects` sections:\n\n buildscript {\n repositories {\n google()\n }\n }\n\n allprojects {\n repositories {\n google()\n }\n }\n\n2. Add the dependencies for the Awareness API to your module's app-level\n Gradle file, which is usually `app/build.gradle`:\n\n dependencies {\n implementation 'com.google.android.gms:play-services-awareness:19.1.0'\n }\n\n3. Add your Awareness API Key to your app's `AndroidManifest.xml` file. To do\n so, add a `\u003cmeta-data\u003e` tag with\n `android:name=\"com.google.android.awareness.API_KEY\"`. For `android:value`,\n insert your own Awareness API Key, surrounded by quotation marks.\n\n ```xml\n \u003cmanifest\u003e\n \u003capplication\u003e\n \u003cmeta-data\n android:name=\"com.google.android.awareness.API_KEY\"\n android:value=\"\u003cvar translate=\"no\"\u003eAPI_KEY\u003c/var\u003e\"/\u003e\n \u003c/application\u003e\n \u003c/manifest\u003e\n ```\n4. Add the necessary permissions to your app's `AndroidManifest.xml` file. The\n required permissions vary, depending on the API methods and fence types that\n your app uses.\n\nExample call\n------------\n\nThe following example call to\n[`getDetectedActivity()`](/android/reference/com/google/android/gms/awareness/SnapshotClient#getDetectedActivity())\ndemonstrates how to use the connectionless Google Play services model with the\nAwareness API: \n\n // Each type of contextual information in the snapshot API has a corresponding \"get\" method.\n // For instance, this is how to get the user's current Activity.\n Awareness.getSnapshotClient(this).getDetectedActivity()\n .addOnSuccessListener(new OnSuccessListener\u003cDetectedActivityResponse\u003e() {\n @Override\n public void onSuccess(DetectedActivityResponse dar) {\n ActivityRecognitionResult arr = dar.getActivityRecognitionResult();\n // getMostProbableActivity() is good enough for basic Activity detection.\n // To work within a threshold of confidence,\n // use ActivityRecognitionResult.getProbableActivities() to get a list of\n // potential current activities, and check the confidence of each one.\n DetectedActivity probableActivity = arr.getMostProbableActivity();\n\n int confidence = probableActivity.getConfidence();\n String activityStr = probableActivity.toString();\n mLogFragment.getLogView().println(\"Activity: \" + activityStr\n + \", Confidence: \" + confidence + \"/100\");\n }\n })\n\nNext steps\n----------\n\nLearn more about the different APIs within the Awareness API:\n\n- [Snapshot API guide](/awareness/android-api/snapshot-api-overview) and [Snapshot API reference](/android/reference/com/google/android/gms/awareness/snapshot/package-summary).\n- [Fence API guide](/awareness/android-api/fence-api-overview) and [Fence API\n reference](/android/reference/com/google/android/gms/awareness/fence/package-summary)."]]