Battery & Power Interview Questions
PERFORMANCE › Runtime
Walk me through how you'd decide whether a piece of background work belongs in WorkManager, a foreground service, or FCM push.
What a strong answer covers: A strong answer frames it as three questions: is the work deferrable, meaning it can wait for a maintenance window or a network/charging constraint, versus time-critical; does the user need to see it's happening, which implies a foreground service for ongoing visible work the OS shouldn't defer; and does it originate server-side needing to reach the device promptly, which points to FCM, high-priority for time-sensitive delivery. WorkManager owns deferrable constrained background work, foreground service owns ongoing user-visible work, and FCM owns server-initiated events.
When would you reach for a foreground service over WorkManager, even though it's more invasive to the user with a persistent notification? What's the trade-off you're weighing?
What a strong answer covers: Reach for a foreground service when work is ongoing and immediate rather than a deferrable one-off task, like live location tracking, audio playback, or an active call, where WorkManager's deferred or batched execution model would introduce unacceptable latency or get killed by Doze. The trade-off is user trust and perceived battery drain: a persistent notification is intrusive and can itself trigger battery-optimization complaints, so it should only be used when work genuinely needs to survive backgrounding in real time, not as a workaround to dodge WorkManager constraints.
Your app's uninstall and battery-complaint rate ties back to a background sync feature. Walk me through how you'd investigate and fix it without just telling users to disable battery optimization.
What a strong answer covers: A strong answer starts with Battery Historian or on-device battery stats to identify what's actually keeping the device awake, wake locks, frequent wakeups, or radio usage from polling, and checks whether sync uses exact alarms or frequent unconstrained WorkManager runs instead of batched, constrained jobs. The fix targets reducing wake frequency, adding constraints like battery-not-low and unmetered network, replacing polling with FCM push, and batching work, rather than reflexively asking users to disable battery optimization, which just masks the underlying inefficiency.