Interview frequency: …
Short answer
A cold start begins from scratch by creating the process and the Application; a warm start only recreates the Activity; and a hot start brings the app back to the foreground immediately from memory. Startup is improved by deferring initialization of unnecessary libraries.
Explanation
A cold start is the longest and the most sensitive to the user's impression. To improve it, reduce the code executed inside Application.onCreate(), use the App Startup library to combine content providers into one initializer, and avoid using reflection or synchronous disk reads while the app opens.
Code example
// Use Jetpack App Startup to organize initialization:
class AnalyticsInitializer : Initializer<Analytics> {
override fun create(context: Context): Analytics {
return Analytics.init(context)
}
override fun dependencies(): List<Class<out Initializer<*>>> = emptyList()
}Common mistakes
- Initializing all analytics, ads, and tool libraries sequentially and synchronously inside Application.onCreate().