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


    Android Developer

    Small and Modern GmbH
    Hamburg, Remote (Germany)
    • Full Time
    apply now

    Senior Android Developer (Remote)

    Komoot
    Europe
    • Full Time
    apply now

    Android Build Engineer

    Pinterest
    San Francisco, CA | Seattle, WA
    • Full Time
    apply now
Load more listings

OUR VIDEO RECOMMENDATION

,

Leveling Up Your Tests

We all know about TDD and Unit Testing, and even screenshot testing, but sometimes we do not need to embrace a new paradigm to make our tests better. These are several techniques I have adopted…
Watch Video

Leveling Up Your Tests

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

 

Thanks to Marcel Pintó and Bruno Kenji Tiba.

YOU MAY BE INTERESTED IN

YOU MAY BE INTERESTED IN

blog
Glance is a recent addition to the suite of Jetpack libraries. It was introduced…
READ MORE
blog

Android 12 review for developers

The Google I/O’21 conference took place, and we learned absolutely everything about the new…
READ MORE

Leave a Reply

Your email address will not be published.

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

Menu