
Android App Widgets: Configuration and Updates with Jetpack Glance
App Widgets provide quick access to app functionality from the home screen. Jetpack Glance simplifies widget development with a Compose-like API. Declaring a Widget <appwidget-provider xmlns:android= "http://schemas.android.com/apk/res/android" android:minWidth= "180dp" android:minHeight= "180dp" android:updatePeriodMillis= "3600000" android:widgetCategory= "home_screen" android:initialLayout= "@layout/widget_layout" android:previewImage= "@drawable/widget_preview" /> Creating a Glance App Widget class MyAppWidget : GlanceAppWidget () { override suspend fun provideGlance ( context : Context , id : GlanceId ) { provideContent { WidgetContent () } } } @Composable private fun WidgetContent () { Column ( modifier = GlanceModifier . fillMaxSize (). padding ( 12 . dp ), verticalAlignment = Alignment . CenterVertically ) { Text ( text = "My Widget" , style = TextStyle ( fontSize = 18 . sp , fontWeight = FontWeight . Bold ) ) Button ( text = "Click Me" , onClick = actionRunCallback ( :: onWidg
Continue reading on Dev.to Tutorial
Opens in a new tab




