-
-
Save kasem-sm/6376cd6b42405c90c8d6e6c2b45eb2e8 to your computer and use it in GitHub Desktop.
When Jetpack's Glance met his fellow worker, Work Manager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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