I’m developing an application using Jetpack Compose and I have some widgets created using Glance Widget. I need to update a counter on the widget every time I receive a notification in the application. Notifications can arrive very frequently, up to 4 times per second, but can also have larger intervals of 10-15 seconds.
To update the widget, I’m using the
suspend fun GlanceAppWidget.updateAll(context: Context): Unit
method every time a notification is received. However, I’m encountering an issue where the widget sometimes updates the counter but sometimes it doesn’t.
My questions are:
- Are there any limitations on how often a widget can be updated using Glance?
- What is the best approach to ensure the widget reliably updates the counter every time a notification is received, especially considering the high frequency of updates?
Any advice or best practices would be greatly appreciated!