activity啓動流程速記筆記

Activity.startActivity(Intent intent)----Activity.startActivityForResult(Intent intent)----Instrumentation.execStartActivity()----ActivityManagerNative.getDefault().startActivity----ActivityManagerService----Binder----IActivityManager----ActivityManagerProxy----ActivityManagerService.startActivity----ActivityManagerService.startActivityAsUser設置了userId-----ActivityStackSuperviso.startActivityMayWait主要進行了Intent的檢查----ActivityStackSuperviso.startActivityLocked生成ActivityRecord-----ActivityStackSuperviso.startActivityUncheckedLocked首先判斷了啓動模式------上面的步驟完成了Activity的目標棧的判斷(targetStack)------ActivityStack.startActivityLocked將Activity添加到了棧頂,初始化了WindowManager--------StackSupervisor.resumeTopActivitiesLocked判斷目標任務棧是否在前------ActivityStack.resumeTopActivityLocked確保當前棧頂的Activity是否resumed-------ActivityStack.resumeTopActivityInnerLocked 1,首先讓如今正在運行的Activity調用startPausingLocked進入pause狀態 2.若是要啓動的Activity不爲空且所在的進程存在的話,所在的進程執行scheduleResumeActivity啓動Activity  3.若是Activity爲空,所在的進程不存在,執行ActivityStackSupervisor.startSpecificActivityLockedjava

 

 

 

ActivityStack.startPausingLocked-------ApplicationThread.schedulePauseActivity主要handler發送消息-----ApplicationThread.handlePauseActivity----ApplicationThread.performPauseActivity----- callCallActivityOnSaveInstanceState(r)----Instrumentation.callActivityOnPause---Activity.performPause---Activity.onPause()

 
 

ApplicationThread.handleReusmeActivity----ApplicationThread.performReusmeActivity----- Instrumentation.callActivityOnReusme---Activity.performReusme---Activity.onReusme()

 

 

 

ActivityStackSupervisor.startSpecificActivityLocked------ActivityManagerService.startProcessLocked-----Process.start方法,而且傳入類名android.app.ActivityThread-------startViaZygote-----zygoteSendArgsAndGetResult最後經過Zygote孵化出了咱們剛纔傳入的ActivityThread,也就是咱們很熟悉的應用入口進程,來到它的main方法----ActivityThread.main()------ Looper.prepareMainLooper()Looper.loop();----ActivityThread thread = new ActivityThread(); thread.attach(false)---------ActivityManagerService.attachApplication----------ActivityManagerService.attachApplicationLocked-------ActivityStackSupervisor.realStartActivityLocked-------ApplicationThread.scheduleLaunchActivity-----ActivityThread.handleLaunchActivity----ActivityThread.performLaunchActivity----packageInfo.getClassLoader()   mInstrumentation.newActivity----- activity.attach(---- mInstrumentation.callActivityOnCreate   activity.performStart();  mInstrumentation.callActivityOnRestoreInstanceState(----- prePerformCreate(activity); activity.performCreate(icicle, persistentState); postPerformCreate(activity);---activity.performCreate()----activity.Create()

相關文章
相關標籤/搜索