Android: When does application’s onCreate() method get called?

3.6 Splash Image

1. Understanding the application class

2. Custom Application classes

  • Specialized tasks that need to run before the creation of your first activity
  • Global initialization that needs to be shared across all components (crash reporting, persistence)
  • Static methods for easy access to static immutable data such as a shared network client object

3. Application:

  • onCreate() - called before the first components of the application starts
  • onLowMemory() - called when the Android system requests that the application cleans up memory
  • onTrimMemory() - called when the Android system requests that the application cleans up memory. This message includes an indicator in which position the application is. For example the constant TRIM_MEMORY_MODERATE indicates that the process is around the middle of the background LRU list; freeing memory can help the system keep other processes running later in the list for better overall performance.
  • onTerminate() - only for testing, not called in production
  • onConfigurationChanged() - called whenever the configuration changes

4. Question

5. Answer

6. Limitations and Warnings

--

--

🎓 “A person who never made a mistake never tried anything new.” —Albert Einstein

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Leo N

🎓 “A person who never made a mistake never tried anything new.” —Albert Einstein