Reputation: 1246
In the the below medium article written by a Google Android Engineer, it states that the best way to fetch data in a glance widget is to use WorkManager
.
The best way to fetch data asynchronously from the background is by using WorkManager and storing the data as recommended in the Guide to background work. The important part is to avoid launching new workers either consecutively (for example, inside GlanceAppWidgetReceiver.onUpdate) or when data is already loaded.
So how do you use WorkManager
inside the content()
function of GlanceAppWidget()
? Can someone please provide a working example?
https://medium.com/androiddevelopers/demystifying-jetpack-glance-for-app-widgets-8fbc7041955c
Upvotes: 0
Views: 858
Reputation: 564
You could check this article where it demonstrates a practical example of how to schedule image downloading/displaying on a Glance widget with WorkManager
Upvotes: 1