Activity的启动流程(加入根Activity逻辑)
2020-07-13 15:40:12 1 举报
Activity的启动全流程(含根activity和普通activity)
作者其他创作
大纲/内容
handleResumeActivity
realStartActivityLocked
execStartActivity
scheduleTransaction
Binder
ResumeActivityItem
resumeTopActivityInnerLocked
performLaunchActivity
1. 创建activity实例2 创建Application对象,调用了Application的onCreate方法。3. activity.attach方法。4. 调用Activity的onCreate方法
LaunchActivityItem
handMessage(切到主线程)
attach
Launcher
TransactionExecutor
H
ActivityTaskManagerService
1、调用IApplicationThread的bindApplication方法,IPC操作,创建绑定Application;2、通过makeActive方法赋值IApplicationThread(创建进程后赋值)3、通过ATMS启动 根activity
startSpecificActivityLocked
startActivityUnchecked
是
Process
attachApplicationLocked
ActivityStack
startActivitySafely
1、通过Zygote进程通过fork孵化了子进程2、创建Binder线程池3、用反射获取到ActivityThread并执行main方法,内容走attach方法
ActivityManagerService
executeLifecycleState
ActivityThread
Launcher(Activity)
execute
startActivity
Zygote
system_server
resumeTopActivityUncheckedLocked
ActivityStackSupervisor
start
Activity
Instrumentation
是否有进程?
startActivityForResult
进入子进程
1. 调用生命周期onStart、onResume2. 设置视图可见(所以视图的真正可见是在onResume方法之后)
否
handleLaunchActivity
scheduleTransaction(执行在Bind线程池)
APP
attachApplication
ApplicationThread
startActivityAsUser
executeCallbacks
startProcessLocked
socket
1、ClientTransaction添加了LaunchActivityItem实例2、使用ATMS的ClientLifecycleManager的scheduleTransaction方法,发送ClientTransaction(还使用clientTransaction.setLifecycleStateRequest方法添加了ResumeActivityItem)3、内部调用了 IApplicationThread的scheduleTransaction方法,即IPC操作
ActivityStarter
0 条评论
下一页