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

,

Let’s test the full widget tree!

In ‘full tree’ widget tests instead of writing widget tests exercising just 1 widget in separation, we set up the whole path user would have to follow to get to this widget.
Watch Video

Let’s test the full widget tree!

Alicja Ogonowska
Flutter Developer
EQUIQO

Let’s test the full widget tree!

Alicja Ogonowska
Flutter Developer
EQUIQO

Let’s test the full widget tree!

Alicja Ogonowska
Flutter Developer
EQUIQO

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

How to animate BottomSheet content using Jetpack Compose

Early this year I started a new pet project for listening to random radio…
READ MORE
blog
Yes! You heard it right. We’ll try to understand the complete OTP (one time…
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