Piotr Prus
03/08/2022, 1:13 PMWorker
using updateAppWidgetState
? I have tried to use it in Worker, but the update function need to be used from GlanceWidget class or I have to pass the GlanceStateDefinition
. So the question is, can I create the State Definition inside my worker?
If not, what is the way to update the widget from Worker
? I found that passing my state in constructor of MyGlanceWidget works, but then I am not using widgetState at all.Piotr Prus
03/08/2022, 8:59 PMval glanceId = GlanceAppWidgetManager(appContext).getGlanceIds(MyWidget::class.java).first()
MyWidget().apply {
updateAppWidgetState(appContext, glanceId) { prefs ->
// update the preferences, ex: prefs[myVariableKey] = true
}
// Manually trigger update of widget
update(appContext, glanceId)
}