GlanceWearWidgetManager

class GlanceWearWidgetManager


Manager for Glance Wear Widgets.

This is used to query the wear widgets currently active on the system.

Summary

Public constructors

Creates a new GlanceWearWidgetManager, providing an interface to check which tiles or widgets are currently present on the system surfaces.

Public functions

suspend List<ActiveWearWidgetHandle>

Returns all currently active widgets and tiles associated with the calling package.

suspend List<ActiveWearWidgetHandle>

Returns the currently active widgets associated with the specified component class.

Public constructors

GlanceWearWidgetManager

Added in 1.0.0-alpha04
GlanceWearWidgetManager(context: Context)

Creates a new GlanceWearWidgetManager, providing an interface to check which tiles or widgets are currently present on the system surfaces.

This instance is designed for reuse and can be maintained as a singleton within your application.

Parameters
context: Context

The application context.

Public functions

fetchActiveWidgets

suspend fun fetchActiveWidgets(): List<ActiveWearWidgetHandle>

Returns all currently active widgets and tiles associated with the calling package.

A widget or a tile instance is active when it was added by the user to a widget or tile surface.

This includes:

Note: A ContainerInfo.CONTAINER_TYPE_FULLSCREEN result represents either a standard TileService or a GlanceWearWidgetService running in compatibility mode.

Legacy Behavior (Pre-API 34): On SDKs prior to Android 14 (U), this method uses a best-effort approach to approximate platform behavior and may be incomplete. Results may omit pre-installed tiles or widgets, tiles or widgets not visited within the last 60 days, or all tiles or widgets if the user has cleared app data. Conversely, tiles or widgets removed via an app update may incorrectly persist as "active" for up to 60 days post-removal.

fetchActiveWidgetsForProvider

suspend fun fetchActiveWidgetsForProvider(clazz: KClass<GlanceWearWidgetService>): List<ActiveWearWidgetHandle>

Returns the currently active widgets associated with the specified component class.

This method filters the results to only include widgets belonging to the provided clazz. A widget instance is considered active when the user has added it to a system surface (such as a widget host or carousel).

Note: A ContainerInfo.CONTAINER_TYPE_FULLSCREEN result indicates that the widget is running in compatibility or fullscreen mode.

Legacy Behavior (Pre-API 34): On SDKs prior to Android 14 (U), this method uses a best-effort approach to approximate platform behavior and may be incomplete. Results may omit pre-installed widgets, those not visited within the last 60 days, or all widgets if the user has cleared app data. Conversely, widgets removed via an app update may incorrectly persist as "active" for up to 60 days post-removal.

Parameters
clazz: KClass<GlanceWearWidgetService>

The component class of the GlanceWearWidgetService used to filter the results.