0Pricing
Android Academy · Lesson

Periodic and Chained Work

Repeat and sequence background tasks.

Periodic and Chained Work is a free Android Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Android Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Periodic and Chained Work

Beyond one-shot tasks, WorkManager can repeat work on a schedule and chain multiple workers so they run in sequence. This lesson covers both.

PeriodicWorkRequest

For recurring work, use PeriodicWorkRequestBuilder, specifying a repeat interval. WorkManager re-runs the worker once per interval.

val periodic = PeriodicWorkRequestBuilder<SyncWorker>(
    repeatInterval = 1,
    repeatIntervalTimeUnit = TimeUnit.HOURS
).build()

The 15-Minute Minimum

The minimum repeat interval is 15 minutes. Requests with a shorter interval are clamped to 15 minutes. This protects battery; WorkManager is not for second-by-second timing.

Periodic Work Is Not Exact

The interval is a guideline, not a precise timer. The system may run the work later to batch jobs and save power. Do not rely on it for time-critical tasks.

Enqueuing Unique Periodic Work

Use enqueueUniquePeriodicWork so you do not stack multiple copies of the same periodic job across app launches.

WorkManager.getInstance(context).enqueueUniquePeriodicWork(
    "daily_sync",
    ExistingPeriodicWorkPolicy.KEEP,
    periodic
)

What Chaining Is

Chaining runs workers in a defined order: step B starts only after step A succeeds. The output of one becomes the input of the next.

beginWith and then

Start a chain with beginWith and add sequential steps with then. Call enqueue to submit the whole chain.

WorkManager.getInstance(context)
    .beginWith(compressRequest)
    .then(uploadRequest)
    .then(cleanupRequest)
    .enqueue()

Data Flows Through the Chain

Output Data from one worker is passed as input to the next. So compressRequest can return a file path that uploadRequest reads from its inputData.

Parallel Steps in a Chain

You can run several workers in parallel by passing a list to beginWith; the next then waits for all of them to finish.

WorkManager.getInstance(context)
    .beginWith(listOf(downloadA, downloadB))
    .then(mergeRequest)
    .enqueue()

Failure Stops the Chain

If any worker returns Result.failure(), the remaining steps in the chain are cancelled. A retry(), however, pauses the chain until that step eventually succeeds.

Combining With Constraints

Each request in a chain or each periodic request can carry its own constraints, so for example only the upload step requires an unmetered network while compression can run anytime.

Quick Check

Test your understanding of periodic and chained work.

Recap

You learned periodic and chained work:

  • PeriodicWorkRequestBuilder repeats work, minimum 15 minutes, not exact
  • beginWith().then() chains workers in sequence
  • Output data flows from one step to the next; lists run in parallel
  • A failure cancels the chain; each step can have its own constraints

You have finished the WorkManager course.

Frequently asked questions

Is the “Periodic and Chained Work” lesson free?

Yes — the full text of “Periodic and Chained Work” is free to read here on the web, and the Android Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Android Academy course, upgrade to CoddyKit PRO.

What will I learn in “Periodic and Chained Work”?

Repeat and sequence background tasks. You practise Android Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Android Academy?

No prior experience is required. Android Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Periodic and Chained Work” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Android Academy lesson?

Yes. Every Android Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. When to Use WorkManager
  2. Creating a Worker
  3. Constraints and Scheduling
  4. Periodic and Chained Work
← Back to Android Academy