#API23
从第一次调用startActivity开始
startActivity(intent);
startActivity(intent,null);
startActivityForResult(intent,-1);
startActivityForResult(intent,-1,null);
android.app.Instrumentation.java->execStartActivity()
这里调用了ActivityManagerNative.getDefault().startActivity->ActivityManagerProxy.startActivity方法
->通过Binder最终调用ActivityManagerService.startActivity
ActivityManagerService.java->startActivity()
添加了callingUserId参数,调用ActivityManagerService.startActivityAsUser
ActivityManagerService.java->startActivityAsUser()
获取了userId,加入了几个参数,调用ActivityStackSupervisor.startActivityMayWait
ActivityStackSupervisor.java->startActivityMayWait()
方法里面有synchronized同步语句块,所以可能等待MayWait,然后调用startActivityLocked
ActivityStackSupervisor.java->startActivityLocked()
ActivityStackSupervisor.java->startActivityUncheckedLocked()
ActivityStack.java->startActivityLocked()
ActivityStackSupervisor.java->resumeTopActivitiesLocked()
ActivityStack.java->resumeTopActivityLocked()
ActivityStack.java->resumeTopActivityInnerLocked()
ActivityStackSupervisor.java->startSpecificActivityLocked()
ActivityManagerService.java->startProcessLocked();
android.os.Process.java->start()->startViaZygote()
android.os.Process.java->zygoteSendArgsAndGetResult()
通过Zygote孵化了一个ActivityThread,去查看ActivityThread的main方法,转到ActivityThread-main
android.app.ActivityThread.java->main()
android.app.ActivityThread.java->attach()
ActivityManagerService.java->attachApplication()
ActivityStackSupervisor.java->attachApplicationLocked()
ActivityStackSupervisor.java->realStartActivityLocked()
ActivityThread.java->scheduleLaunchActivity()
ActivityThread.java->handleLaunchActivity()
ActivityThread.java->performLaunchActivity()
Instrumentation->callActivityOnCreate()
Activity->performCreate()
走到这里就执行了onCreate();
com.android.server.am.ActivityStackSupervisor.java
android.app.Instrumentation.java
com.android.server.am.ActivityManagerService.java
com.android.server.am.ActivityStack.java
android.app.ActivityThread.java