0

To use WorkManager you have to subclass one of the available Worker classes:

I want to run the job every 2 hours. Some of the answers mentioned should be use Listenable Worker. I am confusing this which one suits to this scenario. Please help me on this.

pfmaggi
  • 6,116
  • 22
  • 43
Krishna
  • 143
  • 2
  • 10

1 Answers1

1

WorkManager has some extensive documentation on how to use it that also includes a migration guide covering the move from Firebase JobDispatcher.

In the documentation you can find a section that explain the different threading behaviour of the different Worker classes.

In your particular case, it really depends if what you want to execute periodically is synchronous or not.

  • If what you want to run is synchronous: use a Worker
  • If what you want to run asynchround: use a CoroutineWorker if you're using Kotlin, otherwise you've to use a ListenableWorker.
pfmaggi
  • 6,116
  • 22
  • 43