glance-widget-over-existing-state
Installation
SKILL.md
A widget over the state the app already has
Android only. The widget is not a second app. It is a second renderer of the same state, and it gets there by being a dependency-injection component itself:
// adapted — the widget itself is a dependency-injection component
class MainAppWidget : GlanceAppWidget(), DiComponent {
val playerStateHolder: PlayerStateHolder by inject()
val serviceScope: CoroutineScope by inject(named(SERVICE_SCOPE))
…
}
class AppWidgetReceiver : GlanceAppWidgetReceiver() { // the receiver is a one-liner
override val glanceAppWidget: GlanceAppWidget = MainAppWidget()
}
Two consequences worth being explicit about: