Skip to content

Instantly share code, notes, and snippets.

@kasem-sm
Last active Jun 1, 2022
Embed
What would you like to do?
When Jetpack's Glance met his fellow worker, Work Manager
suspend fun updateWidget(articleTitle: String, context: Context) {
// Iterate through all the available glance id's.
GlanceAppWidgetManager(context).getGlanceIds(MyWidget::class.java).forEach { glanceId ->
updateAppWidgetState(context, glanceId) { prefs ->
prefs[stringPreferencesKey("article_title_key")] = articleTitle //new value
}
}
MyWidget().updateAll(context)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment