WorkManager lên lịch background work có thể defer được, tồn tại qua app restart và system reboot.
- Nó tự động xử lý Doze Mode và App Standby, chọn cơ chế scheduling tốt nhất (JobScheduler, BroadcastReceiver).
- Dùng cho tác vụ đáng tin cậy, không khẩn cấp như sync data, upload file, hay báo cáo định kỳ.
- Tạo
Workersubclass, dùngOneTimeWorkRequesthoặcPeriodicWorkRequest, và enqueue vớiWorkManager.enqueue().
WorkManager schedules deferrable background work that survives app restarts and system reboots.
- It automatically handles Doze Mode and App Standby, choosing the best scheduling mechanism.
- Use for reliable, non-urgent tasks like syncing data, uploading files, or periodic reports.
- Create
Workersubclasses, useOneTimeWorkRequestorPeriodicWorkRequest, and enqueue withWorkManager.enqueue().