Android App cold/hot/warm start

Android App launch

App startup is generally started from the Launcher, and App startup is generally divided into three startup situations: cold/hot/warm

  • Cold start: The program starts from the beginning, and the system does not create a process for the program. General scenario: the first startup after the program is installed; the application is completely terminated by the system and then opened;
  • Warm start: At this time, the program still resides in memory, but is brought to the foreground by the system from the background, so the program can avoid repeated object initialization, loading layout and rendering. It should be noted that if some memory of the program is cleared by the system, such as calling the onTrimMemory method, these objects need to be recreated in response to the startup event.
  • Warm start: It includes a series of operation subsets of hot start and cold start, which consumes slightly more than hot start. The biggest difference between it and the hot start is that it must start to recreate the activity by calling the onCreate method, and it can also obtain the restoration of certain objects from the strength state saved in the onCreate method.

Cold start process

  1. Load and start the app
  2. A blank startup window is displayed for the App immediately after startup (cause of black and white screen)
  3. Create App process (create application object)
  4. Create the main activity
  5. Load layout, draw

to sum up

App is called from the system, and then the first page is rendered to the phone screen. We usually only need to pay attention to the onCreate method in the Application, the onCreate, onStart, and onResume methods in the first Activity.

Note: If when the App starts the first Activity, the Activity not only has its own logic, but also jumps directly to other Activity pages in the onCreate, onStart or onResume methods, then the three methods of the Activity after the jump are required optimize.

Guess you like

Origin blog.csdn.net/yanwenyuan0304/article/details/106279241