When you start a new process to run a App/Service, finally in ActivityManagerService.java, there is:
final String entryPoint = "android.app.ActivityThread";
return startProcessLocked(hostingType, hostingNameStr, entryPoint, app, uid, gids,
runtimeFlags, mountExternal, seInfo, requiredAbi, instructionSet, invokeWith,
startTime);
Which finally calls Process.start. This is the same with the standard java, you pass in a class then the VM create a new process and execute main() of ActivityThread.java:
public static void main(String[] args) {
......
Looper.loop();
throw new RuntimeException("Main thread loop unexpectedly exited");
}
The main function will trigger some action that send IPC message to notify Activity Manager that the process has started successfully, then after notifying the process that initiate the start of the new process of this event, Activity Manager will notify the new process to do the real activity startup process, which create the Activity class according to the manifest then call OnCreate etc.
There is a few answer here that is totally wrong which get a lot of votes, hope a moderate etc can check this.