`
daojin
  • 浏览: 690332 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

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

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics