android-process life cycle A process level
is prioritized as follows:
1 active Processes: Active process
The existence period
is in the activity Resume () [Activity restart] State
is in the state that is interacting with the bound service
is in a state where the service is running in the foreground (Setforeground () is called, The function sets the thread that creates the specified window to the foreground and activates the window)
Service lifecycle function is being executed (onCreate (), Onstrat (), Ondestory ())
Broadcast Receiver is executing the Onreceiver () method
killing foreground process requires the user to do so because the security priority is highest
security priority is highest and is not easily killed
2 visible Process: visble Processes
The current process is not the focus process, activity is not displayed at the front
but it is not completely hidden, can be seen, such as a popup dialog
3 service process: Started Services Processes
A running activity process that does not have a service
4 Background process: Backgroud process
Invisible state in either of the two States, and no related service runs (OnStop () is called). The system has a background
process list, which generally takes the principle of last in, first out (queue) to release background process resources
5 Empty processes: Empty process
does not run any components of the process, leaving this process primarily for caching needs, For example, the next time you start this process can be faster
Two Android app startup and extinction process
Start
by Packagemanage (dependent on Packagemanageservice, Also related to the manifest file) begins->start The main activity-> main activity does not exist--zygote system daemon
Instantiates a virtual machine process, load Dex file
Exit
Auto-release
Kernel->dirvers (Driver)->misc->lowmemorykiller.c file (Implementation mechanism) soft drive
3 ways to Exit program code
Finish ();
System.exit (0); violence exits
Process.killprocess (Process.mypid ()); violence exits
Android-Process life cycle