Android 四大组件 之 start_activity流程

本文详细解析了system_server中源Activity启动目标Activity的过程,包括准备阶段、暂停源Activity、创建目标应用进程和目标Activity线程的附加四个核心步骤,并深入探讨了Application的onCreate主要作用于创建根植于此Application上的各个组件的Context。强调通过亲自debug跟踪以深入理解代码逻辑的重要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

好了,用上篇介绍的工具,跟踪了下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跟踪下,看别人的博客永远只是参考,而且容易打瞌睡。



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值