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

Job Offers

Job Offers

There are currently no vacancies.

OUR VIDEO RECOMMENDATION

, ,

Simplify Design Systems and Designer/Developer Collaboration with Widgetbook

Abstract:Creating beautiful UI has never been easier with Flutter. However, managing and organizing widgets effectively can pose challenges for developers, particularly when it comes to organizing them, testing them in all their different use cases,…
Watch Video

Simplify Design Systems and Designer/Developer Collaboration with Widgetbook

Lucas Josefiak
CEO & Co-Founder
Widgetbook

Simplify Design Systems and Designer/Developer Collaboration with Widgetbook

Lucas Josefiak
CEO & Co-Founder
Widgetbook

Simplify Design Systems and Designer/Developer Collaboration with Widgetbook

Lucas Josefiak
CEO & Co-Founder
Widgetbook

Jobs

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
Menu