Activity启动流程

第一阶段:

对栈的处理。

具体流程:

1.ActivityStackSupervisor.startActivityMayWait

1.resolveActivity

2.getFocusedStack

3.Deal with heavy weight process.

4.startActivityLocked(并没有真正启动,而是异步的)

5.updateConfiguration.

2.ActvityStackSupervisor.startActivityLocked

1.resultTask&resultRecord&resultWho

2.voice compatible

3.check component permission(the activity is exported?  android:permission's protect level?)

4.IntentFireWall

5.ActivityController

6.new ActivityRecord

7.getFocusStack

8.check can switch? 5 seconds delay start and add to pending start activity list. if yes, the following steps will not occur.(APP_SWITCH_DELAY_TIME)

9.mDidAppSwitch = true

10.doPendingActivityLaunches

11.startActivityUncheckedLocked.

3. ActivityStackSupervisor.startActivityUncheckedLocked.

       1. deal with FLAG_ACTIVITY_MULTI_TASK and so on

2.deal with singgleTask, singleInstance and singleTop lauchMode and so on3.solve intentActivity.

if( (launchFlags & Intent.FLAG_ACTIVITY_NEW_TASK) != 0 &&
                (launchFlags & Intent.FLAG_ACTIVITY_MULTIPLE_TASK) == 0)
                || launchSingleInstance || launchSingleTask)

so we want to reuse exited task, so find it as intentActivity.

 

4.if intentActivity is getted, so addingToTask?  reuseTask is getted? or

addingToTask will add the activity to the task

reuseTask is the task that should be reused.

if(!addingToTask && reuseTask == null){

     just bringcurrent task to front. END

}else{

   go step 5

}

5.if Intent.FLAG_ACTIVITY_NEW_TASK and not addingToTask,so create a new task if reuseTask  is null, and set newTask as true to indicate the activity is a new task's root.

6.if FLAG_ACTIVITY_CLEAR_TOP or FLAG_ACTIVITY_REORDER_TO_FRONT just

deliverNewIntentLocked else setTask as sourceTask. END, else go 7

7.targetStack is founded during step 4, 5, 6

8.ActivityStack.startActivityLocked is called.

第二阶段:对Activity的处理

4.  ActivityStack.startActivityLocked

1.insertTaskAtTop

2.addActivityToTop

3.ActivityStackSupervisor.resumeTopActivityLocked

5.ActivityStackSupervisor.resumeTopActivityLocked

1.ActivityStack.resumeTopActivityLocked

2.ActivityStack.resumeTopActivityInnerLocked.

3.if mResumedActivity is not null, ActivityStack.startPausingLocked else just do resume(not happen this time)

4.ActivityThread.ApplicationThread.schedulePauseActivity

5.ActivityManagerService.activityPaused

6.ActivityManagerService.activityPaused

       1.ActivityStack.completePaused.

2.ActivityStackSupervisor.resumeTopActivityLocked

7.ActivityStackSupervisor.resumeTopActivityLocked

1.ActivityStack.resumeTopActivityLocked

        2.ActivityStack.resumeTopActivityInnerLocked.

3.mResumedActivity is null this time, so go to 4

4.if(next.app != null && next.app.thread != null) means activity is create alreally, just call ActivityThread.ApplicationThread.scheduleResumeActivity END else go 5

5.startSpecificActivityLocked if process not exit go 6 else

   call ActivityStackSupervisor.realStartAcitivityLocked  END

6.->startProcess->ActivivityThread.main->ActivityThread.attach->ActivityManagerService.attachApplication

->ActivityManagerService.attachApplicationLocked->ActivityStackSupervisor.realStartAcitivityLocked

 

 

密码管理请下载:

http://a.app.qq.com/o/simple.jsp?pkgname=com.wa505.kf.epassword

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值