Why Mature Android Projects Avoid IdleHandler for Business Timing
Relying on IdleHandler to order business work puts your feature's execution at the mercy of whatever else is hammering the main thread. That turns "run later" into "maybe never," and creates bugs that only reproduce on busy devices or under certain load.
IdleHandler fires whenever the current MessageQueue has no messages to process immediately. That condition has nothing to do with whether a screen is drawn, a user has entered a page, or a feature is ready. Any pending Choreographer frame, handler message, or animation callback later in the queue still leaves a brief idle window, so tasks can run at random, or not at all when the main thread stays busy from scrolling, Compose recomposition, or input events.
Treating IdleHandler as a startup-optimization tool pushes work after first draw, but the actual trigger becomes "the main thread happened to be empty." Login success, onStart, or entering a detail screen are proper triggers; relying on an empty queue turns a clear dependency into a scheduling guess. It also becomes an architecture patch: tasks get scattered across IdleHandlers with implicit ordering, dependencies break, and nobody can reason about execution order.
The alternatives are straightforward: use repeatOnLifecycle for page-visible loads, explicit delay for timed work, WorkManager for background jobs, and View.post or ViewTreeObserver for post-layout tasks. For Application startup, separate core from non-core init and spell out dependencies instead of deferring everything. The rule that emerges: zero IdleHandlers in business code. It's fine for low-priority warmup like logging or object pools, but even those can use explicit async initialization. Mature projects express when a task should run, not hope the main thread has nothing better to do.
IdleHandler conflates two independent timelines: when a business condition is true and when the main thread has nothing to do. That conflation is what makes it unreliable for anything that has a "when" attached.
Adopting IdleHandler as a startup trick quietly hides task ordering decisions; teams stop asking whether A depends on B, because the queue seems to sort it out later. The resulting implicit scheduling turns into maintenance debt.
A zero-IdleHandler rule is less about banning an API and more about forcing explicit triggers for each piece of work. Naming the condition ("after user logs in", "when page is visible") is usually more valuable than any latent performance gain.