一、App启动流程 这里以一张图说明App进程的创建流程: 通过Zygote进程到最终进入到app进程世界,我们可以看到ActivityThread.main()是进入App世界的大门,下面对该函数体进行简要的分析,具体分析请看文末的参考链接。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 5379 public static void main(String[] args) { 5380 Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "ActivityThreadMain" ); 5381 SamplingProfilerIntegration.start(); 5382 5383 // CloseGuard defaults to true and can be quite spammy. We 5384 // disable it here, but selectively enable it later (via 5385 // StrictMode) on debug builds, but using DropBox, not logs. 5386 CloseGuard.setEnabled( false ); 5387 5388 Environment.initForCurrentUser(); 5389 5390 // Set the reporter for event logging in libcore 5391 EventLogger.setRe