Blog Infos
Author
Published
Topics
,
Published
How does it work?
class HelloWorldWidget: GlanceAppWidget() {
@Composable
override fun Content() {
Text(text = "Hello world!")
}
}
class HelloWorldWidgetReceiver : GlanceAppWidgetReceiver() {
override val glanceAppWidget = HelloWorldWidget()
}
It uses its own Compose implementation

Glance App Widget Error example

And a similar stack trace on Logcat:

E/GlanceAppWidget: Error in Glance App Widget
java.lang.IllegalStateException: CompositionLocal LocalDensity not present at androidx.compose.ui.platform.CompositionLocalsKt.noLocalProvidedFor(CompositionLocals.kt:170)
Updating is different from Jetpack Compose

OUR VIDEO RECOMMENDATION

,

How to convert Figma components to Flutter widgets

Creating great user interfaces and an awesome user experience has never been easier with Flutter. However, transforming a design from Figma to Flutter can have its problems.
Watch Video

How to convert Figma components to Flutter widgets

Jens Horstmann
CTO
Widgetbook

How to convert Figma components to Flutter widgets

Jens Horstmann
CTO
Widgetbook

How to convert Figma components to Flutter widgets

Jens Horstmann
CTO
Widgetbook

Jobs

No results found.

User interactions are easier to handle
Button(
text = "Home",
modifier = GlanceModifier.clickable(actionStartActivity<HomeActivity>())
)

It is also possible to create custom actions to better fit your user experience needs:

Button(
text = "Update",
modifier = GlanceModifier.clickable(actionRunCallback<UpdateAction>())
)
class UpdateAction : ActionCallback {
override suspend fun onRun(context: Context, glanceId: GlanceId, parameters: ActionParameters) {
// Update!
}
}
Make sure to test on Android 12 and below
What’s next?

Alkaa Task List Widget

Last December, Google announced the alpha version of Jetpack Glance library for making App Widgets. This new tools allow us to use Jetpack Compose like style, making it faster and easier to create expressive and responsible widgets for our application.

 

Thanks to Marcel Pintó and Bruno Kenji Tiba.

YOU MAY BE INTERESTED IN

YOU MAY BE INTERESTED IN

blog
It’s one of the common UX across apps to provide swipe to dismiss so…
READ MORE
blog
In this part of our series on introducing Jetpack Compose into an existing project,…
READ MORE
blog
In the world of Jetpack Compose, where designing reusable and customizable UI components is…
READ MORE
blog

How to animate BottomSheet content using Jetpack Compose

Early this year I started a new pet project for listening to random radio…
READ MORE

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

Menu