Android Background Work Standards
Priority: P1
Implementation Guidelines
WorkManager
- CoroutineWorker: Use for all background tasks.
- Constraints: Be explicit (Require Network, Charging).
- Hilt: Use
@HiltWorkerfor DI integration. Inject dependencies via@AssistedInjectconstructor; bind withHiltWorkerFactoryinWorkManagerconfiguration.
Foreground Services
- Only When Necessary: Use generating visible notifications only for tasks the user is actively aware of (Playback, Calls, Active Navigation). Otherwise use WorkManager.
Anti-Patterns
- No IntentService: Deprecated. Use WorkManager for all background tasks.
- No Short Background Jobs: Use Coroutines in ViewModel scope instead.