What’s going on Android before we launch an application? Under the hood, the Android Linux kernel runs many daemon processes to manage the system. The first process is called the root process and it is an init
process. You can check what the process does in /system/core/init/.
There are various daemons run in Android. Among of them, Zygote
is a special daemon to launch applications. Its role is for launching apps quickly without a cold start. In other words, the process preloads and initializes core libraries that need to launch apps and it is forked based on copy-on-write policy. You can check what the process can do in /android/internal/os/ZygoteInit.java and what kind of arguments are used in /android/internal/os/ZygoteArguments.java.
The System Server that runs services of Android framework like ActivityManager
is started by Zygote
process. You can check what the server does in /server/SystemServer.java.
Let’s see the following figure.
You can check theZygote
process that starts System Server. The ActivityManager
starts to handle Intent
on Android framework. You can check it with a green line on the figure.
After Zygote
starts System Server, the user can click an application on the device home launcher. Then the click event sends Intent
to launch the application, and the System Server initialized all kinds of service with a preloaded Zygote
process that is ready to be used. You can also check it through the yellow line on the figure.
We can recheck how to Application is launched with the following figure:
- User clicks an app on Launcher.
- The
Intent
is sent to Activity Manager andZygote
is forked withpid
(Zygote::forkAndSpecialize) - Finally, launch the application with Activity Thread.
Although there are lots of good articles relating to this topic online, I hope this article also possibly help someone.