2

Android Oreo (8.0) makes it very hard to update widgets (1,2,3) either by clicking a button (PendingIntent) or automatically updating every X minutes. I am looking into how I could use the new WorkManager for this.

I was able to use if for another task not related to widgets, and it works well. However, I can't find any example (or even a quick outline) on how to use it with widgets to be able to update them periodically (let's say every 5 minutes) and also update them when a RemoteView is clicked. BTW, this requires downloading a file from the internet and displaying contents in RemoteViews.

Has anyone tried it and how did it work out? Are there any examples?

c0dehunter
  • 6,412
  • 16
  • 77
  • 139

1 Answers1

1

You can use WorkManager which scheduler your Workers using JobScheduler. There is nothing special about a Widget in Android O which makes things different (from WorkManagers perspective).

Rahul
  • 19,744
  • 1
  • 25
  • 29
  • Also, the minimum interval for PeriodicWork is 15 minutes (same as JobScheduler Periodic Job). If you need it every 30 seconds — consider using OneTimeWork and schedule it again when the work is done. – c0dehunter Sep 14 '18 at 06:34