Rebuilding Android Launch and Persistence After Your Process Gets Killed
Android's tightening background execution rules mean any app needing reliable background work must plan for process death and recovery. This architecture provides a compliant, modern pattern that works across Android 14/15/16 and avoids deprecated keep-alive hacks.
The article tackles the messy reality of Android background work: waking an app from a deep link, keeping a task alive, and recovering after the system kills the process. The author redesigns this as a unified five-layer architecture (trigger, launch, session, recovery, observability) instead of three separate bugs. Key pieces include a single router that handles cold/warm/hot starts without losing parameters, a state machine with persisted checkpoints and a user authorization window, and a recovery coordinator that converges four restart paths (START_STICKY, WorkManager, push, user reopening) into one idempotent flow.
Version-specific requirements get heavy treatment: foreground service types and permissions must match exactly between manifest and code, Android 15 caps dataSync at 6 hours daily and requires onTimeout handling, PendingIntent needs explicit mutability flags since 12, and boot broadcasts can only reschedule work. The article also documents a full set of adb commands for testing each layer, and a detailed workflow for using the Trae AI coding assistant with precise prompts, project rules, and iterative debugging patterns, including a compliance checklist for Android 14/15/16 and app store policies.
The article shows that 'keep the process alive' is a lost battle on modern Android; the only viable strategy is making death harmless by persisting state and designing idempotent recovery.
AI code generation (Trae) only becomes useful when strict constraints are embedded in project rules and each generation round includes verification commands; without that, it produces outdated or version-blind code.
The comprehensive version table highlights how Android's background execution limits have effectively forced developers to adopt explicit, observable, and user-controllable background patterns—a shift that aligns background apps with privacy and battery expectations.
The emphasis on compliance (purpose dialogs, stop buttons, authorization windows) suggests that in the Chinese app ecosystem, regulatory scrutiny now shapes technical architecture as much as OS constraints do.