tezvyn:

Explain cold, warm, and hot app startups and three cold-start optimizations

AI-drafted, machine-checkedSource: developer.android.comintermediate
Explain cold, warm, and hot app startups and three cold-start optimizations
WHAT IT TESTS

App startup modes and tuning tactics.

ANSWER OUTLINE

Cold means no process; warm means process lives but activity recreates; hot means activity resumes. Three fixes: lazy-load deps, trim Application.onCreate, defer blocking I/O.

WHAT THIS TESTS: This question probes whether you understand the Android process and activity lifecycle well enough to distinguish how much work the system must do before the user sees the first frame. It also checks if you can move beyond theory to name specific measurable optimizations that target cold starts where no process exists yet.

A GOOD ANSWER COVERS: First the three definitions in order of cost. A cold start happens when the system creates your application process from scratch so it must load and initialize the Application object create the main activity and inflate the entire view hierarchy. A warm start occurs when the process is still alive in memory but the activity must be recreated which skips some process setup but still pays inflation and onCreate costs. A hot start is the cheapest because the activity was only paused and is simply resumed so the window just moves to the foreground. Second three concrete optimizations. One lazy-load dependencies that are not needed for the first frame by using a dependency injection framework or the App Startup library to avoid initializing every library inside Application onCreate. Two audit and minimize the work inside Application onCreate and the main activity onCreate because every millisecond there delays the first draw. Three move blocking disk reads network calls and heavy object construction off the main thread using background dispatchers or asynchronous initialization patterns so the UI thread can render the first frame immediately.

COMMON WRONG ANSWERS: Many candidates conflate warm and hot starts or claim that warm starts always involve a dead process. Others give generic platitudes like reduce memory usage or use a faster device instead of naming specific code changes. Suggesting multithreading without explaining what work moves off the main thread is also weak. A senior red flag is ignoring the Application class entirely and only talking about activity-level optimizations since cold start time is dominated by process creation and application initialization.

LIKELY FOLLOW-UPS: The interviewer may ask how you profile cold start time in production versus local development what the App Startup library does under the hood or how you would optimize a third-party SDK that insists on initializing in Application onCreate. They might also ask for numbers such as what percentage of cold start time is typically spent in dex loading versus layout inflation on low-end devices.

ONE CONCRETE EXAMPLE: Suppose an e-commerce app takes 2.5 seconds to cold start because it initializes analytics crash reporting and a mapping SDK inside Application onCreate. A strong answer would describe moving analytics and crash reporting to background threads via Kotlin coroutines or WorkManager deferring the mapping SDK until the user opens the store locator screen and using the App Startup library to expose explicit initializer dependencies so the system does not block on unrelated work. This could drop cold start by 800 to 1200 milliseconds on a mid-range device.

Read the original → developer.android.com

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.