首页 > 代码库 > Android start_activity流程

Android start_activity流程

好了,用上篇介绍的工具,跟踪了下startActivity在system_server中的流程,如下:

The picture below is the flow chart for how the source Activity start a target activity

Major includes four steps:
(1) Preparation, flow chart in blue;
(2) suspend the source activity, in yellow;
(3) Start the target application process once not yet created, also create the
Activity Thread, in Aubergine;
(4) Attach the target activity thread to application, in red, in this step,
application onCreate and activity onCreate are invoked.


System_server中的ActivityStack很重,里面维护了所有的activity的状态的栈,由于时间关系,没有深入研究。Application的onCreate主要是创建植根与此Application上的各个组件的Context。

有一点心得是如果要比较深入了解,必须自己去debug跟踪下,看别人的博客永远只是参考,而且容易打瞌睡。



Android start_activity流程