Skip to content

Instantly share code, notes, and snippets.

@kasem-sm
Created May 30, 2022 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kasem-sm/14cfc183b9683f99038d9f6bac42e397 to your computer and use it in GitHub Desktop.
Save kasem-sm/14cfc183b9683f99038d9f6bac42e397 to your computer and use it in GitHub Desktop.
When Jetpack's Glance met his fellow worker, Work Manager
class MyWidget() : GlanceAppWidget() {
override val stateDefinition = PreferencesGlanceStateDefinition
@Composable
override fun Content() {
val state = currentState<Preferences>()
val articleTitle = state[stringPreferencesKey("article_title_key")] ?: ""
Text(text = articletitle)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment