رویدادهای چرخه زندگی و تجزیه و تحلیل، چرخه زندگی و رویدادهای تجزیه و تحلیل
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
TileService یک سرویس محدود است. TileService شما در نتیجه درخواست برنامه شما یا اگر سیستم نیاز به برقراری ارتباط با آن داشته باشد، محدود می شود. یک چرخه عمر سرویس باند معمولی شامل چهار روش پاسخ به تماس زیر است: onCreate() , onBind() , onUnbind() و onDestroy() . سیستم هر بار که سرویس وارد مرحله چرخه حیات جدید می شود این روش ها را فراخوانی می کند.
با این حال، TileService با اکثر سرویسهای محدود دیگر متفاوت است، زیرا شامل روشهای چرخه حیات خاص TileService نیز میشود. متدهای چرخه عمر Service و متدهای چرخه عمر TileService در دو رشته ناهمزمان مجزا فراخوانی می شوند.
برای اطلاعات بیشتر در مورد این روش ها و رویدادها به مستندات TileService مراجعه کنید.
جستجو کنید کدام کاشیها فعال هستند
کاشی های فعال کاشی هایی هستند که برای نمایش در ساعت اضافه شده اند. از روش استاتیک getActiveTilesAsync()TileService برای پرس و جو اینکه کدام کاشی های متعلق به برنامه شما فعال هستند استفاده کنید.
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Lifecycle and analytics events\n\n`TileService` is a [bound service](/guide/components/bound-services). Your `TileService` is bound as a result\nof your app request or if the system needs to communicate with it. A typical\n[bound-service lifecycle](/guide/components/bound-services#Lifecycle) contains the following four callback methods:\n[`onCreate()`](/reference/android/app/Service#onCreate()), [`onBind()`](/reference/android/app/Service#onBind(android.content.Intent)), [`onUnbind()`](/reference/android/app/Service#onUnbind(android.content.Intent)), and [`onDestroy()`](/reference/android/app/Service#onDestroy()).\nThe system invokes these methods each time the service enters a new lifecycle\nphase.\n\nHowever, `TileService` differs from most other bound services because it also\ncontains `TileService`-specific lifecycle methods. The `Service` lifecycle\nmethods and the `TileService` lifecycle methods are called in two separate\nasynchronous threads.\n\nThere are two categories of `TileService` methods:\n\n- **Methods relating to core Tile functionality.** [`onTileRequest()`](/reference/androidx/wear/tiles/TileService#onTileRequest(androidx.wear.tiles.RequestBuilders.TileRequest)) (mandatory to implement) and [`onTileResourcesRequest()`](/reference/androidx/wear/tiles/TileService#onTileResourcesRequest(androidx.wear.tiles.RequestBuilders.ResourcesRequest)) are in this category.\n- **Methods relating to analytics and visibility.** This includes methods such as:\n - [`onTileAddEvent()`](/reference/androidx/wear/tiles/TileService#onTileAddEvent(androidx.wear.tiles.EventBuilders.TileAddEvent)) called when when the user adds your tile to the carousel\n - [`onTileRemoveEvent()`](/reference/androidx/wear/tiles/TileService#onTileRemoveEvent(androidx.wear.tiles.EventBuilders.TileRemoveEvent)) called when the user removes your tile from the carousel\n - [`onRecentInteractionEventsAsync()`](/reference/androidx/wear/tiles/TileService#onRecentInteractionEventsAsync(java.util.List%3Candroidx.wear.tiles.EventBuilders.TileInteractionEvent%3E)) provides information about recent user and system interactions with tiles\n\nSee the [`TileService`](/reference/androidx/wear/tiles/TileService) documentation for more information about these\nmethods and events.\n\n### Query which tiles are active\n\n*Active tiles* are tiles which have been added for display on the watch. Use\n`TileService`'s static method [`getActiveTilesAsync()`](/reference/androidx/wear/tiles/TileService#getActiveTilesAsync(android.content.Context,java.util.concurrent.Executor)) to query which tiles\n*belonging to your app* are active.\n| **Caution:** The result reflects the list of active tiles at the time the call was made, which might have changed by the time the result is received. Use `onTileAddEvent()` and `onTileRemoveEvent()` callbacks for scheduling actions that need to happen when your tile becomes either active or inactive."]]