0% found this document useful (0 votes)
27 views10 pages

WorkManager - Quick Guide

Uploaded by

denys
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views10 pages

WorkManager - Quick Guide

Uploaded by

denys
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Work Manager

in Android -
Quick Guide

Maksym Trushevych
Senior Android Engineer

@hifeful_it
1
What is WorkManager?
WorkManager is Android's recommended solution
for deferrable, guaranteed background work.

✅ Guaranteed execution (even after app restarts)


✅ Battery optimization friendly
✅ Backwards compatible to API 14
✅ Handles device constraints automatically
2
When to Use
📤 Uploading logs or analytics
💾 Database cleanup tasks
🔄 Syncing data with server
📸 Image compression/processing
📧 Sending reports or backups
Perfect for work that must be completed, even if
your app isn't running!
3
Basic Setup
Getting started with WorkManager is simple - just
add the dependency and create your Worker class!
4
Scheduling Work
Schedule your work with constraints to ensure it runs
at the right time!
5
Work States
🟡 ENQUEUED: Waiting to run
🔵 RUNNING: Currently executing
🟢 SUCCEEDED: Completed successfully
🔴 FAILED: Failed with [Link]()
🟠 CANCELLED: Cancelled by user/system
6
Constraints & Conditions
Control when your work runs with smart constraints:
📶 Network: CONNECTED, UNMETERED,
NOT_ROAMING
🔋 Battery: NOT_LOW_BATTERY
🔌 Charging: CHARGING required
💾 Storage: NOT_LOW_STORAGE
📱 Device: IDLE (Doze mode considerations)
7
Data Passing & Progress
Pass data to your workers and track progress in real-
time!
💾 Input Data: Send parameters to your Worker
📈 Progress Updates: Show real-time progress to
users
📤 Output Data: Return results from completed work
8 Advanced Features
Build complex workflows with these powerful
WorkManager capabilities!

⛓️ Work Chaining: Sequential task execution


🏷️ Unique Work: Prevent duplicate work
📊 Progress Updates: Track work progress
🔗 Work Continuation: Complex workflows
@hifeful_it

Want to learn
more?
Follow for more info

Maksym Trushevych
Senior Android Engineer

You might also like