| license | Apache-2.0 |
| name | android-background-task-specialist |
| description | Android background task specialist for WorkManager, Foreground Services, Doze mode, and battery optimization. Activate on: WorkManager, background task Android, Foreground Service, Doze mode, battery optimization, periodic work, background sync Android, JobScheduler. NOT for: iOS background tasks (use swiftui-data-flow-expert), React Native background (use mobile-offline-sync-architect), UI architecture (use jetpack-compose-navigation-expert). |
| allowed-tools | Read,Write,Edit,Bash(gradle:*,adb:*) |
| category | Mobile Development |
| tags | ["android","background-tasks","workmanager","battery"] |
| pairs-with | [{"skill":"jetpack-compose-navigation-expert","reason":"ViewModels and UI layer coordinate with background task results"},{"skill":"mobile-offline-sync-architect","reason":"Background sync is a key offline-first pattern on Android"}] |
Android Background Task Specialist
Expert in Android background execution with WorkManager, Foreground Services, Doze mode handling, and battery-efficient processing.
Activation Triggers
Activate on: "WorkManager", "background task Android", "Foreground Service", "Doze mode", "battery optimization", "periodic work", "background sync", "JobScheduler", "background processing Android"
NOT for: iOS background tasks → swiftui-data-flow-expert | React Native background → mobile-offline-sync-architect | UI architecture → jetpack-compose-navigation-expert
Quick Start
- Choose the right API — WorkManager for deferrable work, Foreground Service for user-visible ongoing tasks, coroutines for short async work
- Define workers — extend
CoroutineWorker with suspend functions for clean async code
- Configure constraints — network type, battery level, storage requirements
- Handle Doze and App Standby — use WorkManager (not AlarmManager) for Doze-compatible scheduling
- Test with adb — force Doze mode and verify work executes when constraints are met
Core Capabilities
| Domain | Technologies |
|---|
| Deferrable Work | WorkManager 2.10, OneTimeWorkRequest, PeriodicWorkRequest |
| Foreground | Foreground Service types (dataSync, location, mediaPlayback, shortService) |
| Constraints | NetworkType, BatteryNotLow, StorageNotLow, DeviceIdle |
| Chaining | WorkContinuation, parallel chains, unique work policies |
| Testing | TestWorkerBuilder, TestListenableWorkerBuilder, WorkManagerTestInitHelper |
Architecture Patterns
WorkManager Decision Tree
Is the task user-initiated and needs to complete?
├─ YES → Is it short (< 10 min)?
│ ├─ YES → Foreground Service (shortService type)
│ └─ NO → Foreground Service (dataSync, location, etc.)
│
└─ NO → Is it deferrable?
├─ YES → WorkManager
│ ├─ One-time? → OneTimeWorkRequest
│ └─ Periodic? → PeriodicWorkRequest (min 15 min interval)
│
└─ NO → Is it while app is visible?
├─ YES → CoroutineScope (viewModelScope or lifecycleScope)
└─ NO → You probably need WorkManager anyway