Pick the fix
Every app launch enqueues a new periodic sync, and after a week the sync runs dozens of times per hour. Fix?
Hint 1 of 1
How does WorkManager tell two requests are the same job?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A Use enqueueUniquePeriodicWork("sync", ExistingPeriodicWorkPolicy.KEEP, request)
Correct. One named periodic job; later enqueues keep the existing one.
Why not the others?
- B Cancel all work on launch, then enqueue. Cancels unrelated work too, and still races.
- C Increase the interval to 1 hour. Still duplicated, just less often.
- D Move sync to Application.onCreate. Runs on every process start instead.