با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
با استفاده از Google Awareness API، می توانید برنامه خود را فعال کنید تا به طور هوشمندانه به وضعیت فعلی کاربر واکنش نشان دهد. Awareness API پنج نوع زمینه مختلف را نشان میدهد که شامل فعالیت کاربر و چراغهای نزدیک است. این نوعها به برنامه شما امکان میدهند تا تجربه کاربر را به روشهای جدیدی که قبلاً امکانپذیر نبود، اصلاح کند. برنامه شما میتواند این سیگنالهای زمینه را برای استنتاج درباره وضعیت فعلی کاربر ترکیب کند و از این اطلاعات برای ارائه تجربیات سفارشیسازی شده استفاده کند، مانند پیشنهاد لیست پخش زمانی که کاربر هدفون خود را وصل میکند و شروع به دویدن میکند.
مزایای Awareness API
Awareness API چندین مزیت دارد:
سهولت اجرا: فقط باید یک API به برنامه خود اضافه کنید، که یکپارچگی را تا حد زیادی ساده می کند و بهره وری شما را بهبود می بخشد.
داده های زمینه بهتر: سیگنال های خام برای بهبود کیفیت پردازش می شوند. به عنوان مثال، الگوریتم های پیشرفته برای تعیین فعالیت کاربر با سطح دقت بالا استفاده می شود.
سلامت بهینه سیستم: Awareness API به طور خودکار تأثیر خود را بر عمر باتری و مصرف داده مدیریت می کند تا برنامه شما مجبور به انجام آن نباشد.
نرده ها و عکس های فوری
Awareness API از دو API مجزا تشکیل شده است که برنامه شما می تواند از آنها برای دریافت سیگنال های زمینه به منظور تعیین وضعیت فعلی کاربر استفاده کند:
Fence API: این API به برنامه شما اجازه میدهد به وضعیت فعلی کاربر واکنش نشان دهد و در صورت برآورده شدن ترکیبی از شرایط زمینه، اعلان ارائه میکند. به عنوان مثال، هر زمان که کاربر راه میرود و هدفونهایش وصل میشود. پس از ثبت نام حصار، Fence API میتواند حتی زمانی که برنامه شما در حال اجرا نیست، تماسهای برگشتی را به برنامه شما ارسال کند.
Snapshot API: این API به برنامه شما اجازه میدهد اطلاعاتی درباره شرایط فعلی کاربر، مانند مکان فعلی کاربر و شرایط آب و هوایی فعلی درخواست کند.
انواع زمینه
زمینه در قلب API Awareness قرار دارد. دادههای متنی شامل دادههای مشتقشده از حسگر مانند مکان (طول و عرض جغرافیایی)، نوع مکان، مانند پارک یا کافیشاپ، و فعالیتهایی مانند پیادهروی یا رانندگی است. این انواع اساسی یا سیگنال ها را می توان برای برون یابی وضعیت کاربر با جزئیات بیشتر ترکیب کرد. اعلان زیر را گسترش دهید تا ببینید کدام سیگنالهای متنی منسوخ شدهاند.
اطلاعیه منسوخ شدن: مکان ها و سیگنال های متنی آب و هوا
جدول زیر انواع زمینه های اساسی را که در حال حاضر توسط API Awareness ارائه می شود، شرح می دهد:
نوع زمینه
مثال
زمان
زمان محلی فعلی
مکان
طول و عرض جغرافیایی
فعالیت
فعالیت کاربر شناسایی شده، مانند راه رفتن، دویدن یا دوچرخهسواری
چراغ های دریایی
چراغ های نزدیک که با فضای نام مشخص شده مطابقت دارند
تاریخ آخرین بهروزرسانی 2025-09-03 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-09-03 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThe Google Awareness API lets your app intelligently respond to the user's context, such as their activity, location, and nearby beacons.\u003c/p\u003e\n"],["\u003cp\u003eIt offers benefits like easy implementation, improved context data quality, and automatic management of system resources.\u003c/p\u003e\n"],["\u003cp\u003eThe API provides two ways to access context: the Fence API for reacting to situations and the Snapshot API for requesting current information.\u003c/p\u003e\n"],["\u003cp\u003eSupported context types include time, location, activity, beacons, and headphone status, while places and weather signals are deprecated.\u003c/p\u003e\n"]]],[],null,["# What's the Awareness API?\n\nWith the Google Awareness API, you can enable your app to intelligently react to the\nuser's current situation. The Awareness API exposes five different\n[context types](#context-types), which include user activity,\nand nearby beacons. These types enable your app to refine the user experience in\nnew ways that weren't possible before. Your app can combine these context\nsignals to make inferences about the user's current situation, and use this\ninformation to provide customized experiences, such as a playlist suggestion\nwhen the user plugs in their headphones and starts to jog.\n\nAwareness API benefits\n----------------------\n\nThe Awareness API provides several benefits:\n\n- **Ease of implementation:** You only need to add a single API to your app, which greatly simplifies integration and improves your productivity.\n- **Better context data:** Raw signals are processed for improved quality. For example, advanced algorithms are used to determine the user's activity with a high level of accuracy.\n- **Optimal system health:** The Awareness API automatically manages its impact on battery life and data usage so that your app doesn't have to.\n\nFences and snapshots\n--------------------\n\nThe Awareness API consists of two distinct APIs that your app can use to\nget context signals in order to determine the user's current situation:\n\n- [**Fence API:**](/awareness/android-api/fence-api-overview) This API lets your app react to the user's current situation, and provides notification when a combination of context conditions are met. For example, whenever the user takes a walk and their headphones are plugged in. Once a fence is registered, the Fence API can send callbacks to your app even when it's not running.\n- [**Snapshot API:**](/awareness/android-api/snapshot-api-overview) This API lets your app request information about the user's current context, such as the user's current location and the current weather conditions.\n\nContext types\n-------------\n\nContext is at the heart of the Awareness API. Contextual data includes\nsensor-derived data such as location (latitude and longitude), place type,\nlike a park or coffee shop, and activity, such as a walk or drive. These basic\ntypes, or signals, can be combined to extrapolate the user's situation in more\nspecific detail. Expand the following notice to see which contextual signals\nhave been deprecated.\n**Deprecation notice: Places and Weather contextual signals** **Warning:**\n| The Places and Weather contextual signals, exposed by the\n| [`getPlaces()`](/android/reference/com/google/android/gms/awareness/SnapshotClient#getPlaces()), and\n| [`getWeather()`](/android/reference/com/google/android/gms/awareness/SnapshotClient#getWeather())\n| methods, were deprecated.\n|\n| - The Places contextual signal was turned off. Continued use of this signal was restricted to customers with existing implementations, through October 30, 2019. New implementations must use the [Places SDK for Android](/places/android-sdk) instead of the Places contextual signal.\n| - The Weather contextual signal has also been turned off. Continued use of this signal has been restricted to customers with existing implementations, through January 31, 2020. Google doesn't offer alternative functionality for the Weather contextual signal.\n\nThe following table describes the basic context types currently offered by\nthe Awareness API:\n\n| Context type | Example |\n|--------------|----------------------------------------------------------|\n| Time | Current local time |\n| Location | Latitude and longitude |\n| Activity | Detected user activity, like walking, running, or biking |\n| Beacons | Nearby beacons that match the specified namespace |\n| Headphones | Status of whether headphones are plugged in, or not |"]]