AssociateWithGlanceWearWidget

@Target(allowedTargets = [AnnotationTarget.CLASS])
@Retention(value = AnnotationRetention.RUNTIME)
annotation AssociateWithGlanceWearWidget


Annotation used to associate a androidx.glance.wear.GlanceWearWidget class with its corresponding androidx.glance.wear.GlanceWearWidgetService.

This association must be used in androidx.glance.wear.GlanceWearWidgetService to specify which associated widget class it has in its widget property. It must match the exact class name of the widget class used in the property.

This annotation is required so that the androidx.glance.wear.GlanceWearWidget class can be resolved statically from the associated service's metadata without instantiating the service, avoiding initialization issues in services that use dependency injection (e.g., Hilt/Dagger).

For example:

@AssociateWithGlanceWearWidget(MyGlanceWearWidget::class)
class MyGlanceWearWidgetService : GlanceWearWidgetService() {
override val widget = MyGlanceWearWidget()
}

Summary

Public constructors

Public properties

KClass<GlanceWearWidget>

Public constructors

AssociateWithGlanceWearWidget

Added in 1.0.0-alpha16
AssociateWithGlanceWearWidget(value: KClass<GlanceWearWidget>)

Public properties

value

val valueKClass<GlanceWearWidget>