Android App启动流程

1.通过 Launcher 启动应用时,点击应用图标后,Launcher 调用 startActivity 启动应用。

2.Launcher Activity 最终调用 Instrumentation 的 execStartActivity 来启动应用。

3.Instrumentation 调用 ActivityManagerProxy (ActivityManagerService 在应用进程的一个代理对象) 对象的 startActivity 方法启动 Activity。

4.到目前为止所有过程都在 Launcher 进程里面执行,接下来 ActivityManagerProxy 对象跨进程调用 ActivityManagerService (运行在 system_server 进程)的 startActivity 方法启动应用。

5.ActivityManagerService 的 startActivity 方法经过一系列调用,最后调用 zygoteSendArgsAndGetResult 通过 socket 发送给 zygote 进程,zygote 进程会孵化出新的应用进程。

6.zygote 进程孵化出新的应用进程后,会执行 ActivityThread 类的 main 方法。在该方法里会先准备好 Looper 和消息队列,然后调用 attach 方法将应用进程绑定到 ActivityManagerService,然后进入 loop 循环,不断地读取消息队列里的消息,并分发消息。

7.ActivityManagerService 保存应用进程的一个代理对象,然后 ActivityManagerService 通过代理对象通知应用进程创建入口 Activity 的实例,并执行它的生命周期函数。

相关推荐
2501_916007473 小时前
iOS 26 软件性能测试 新版系统下评估全流程 + 多工具辅助方案
android·macos·ios·小程序·uni-app·cocoa·iphone
云霄IT3 小时前
绕过Frida检测反调试的一些办法
android·javascript
sang_xb4 小时前
Android 如何开启 16KB 模式
android·kotlin
alengan4 小时前
安卓上谷歌35版本
android
珹洺5 小时前
Java-Spring入门指南(二十五)Android 的历史,认识移动应用和Android 基础知识
android·java·spring
大白的编程日记.5 小时前
【MySQL】数据库表的CURD(二)
android·数据库·mysql
介一安全6 小时前
【Frida Android】基础篇4:Java层Hook基础——调用静态方法
android·网络安全·逆向·安全性测试·frida
怪兽20146 小时前
主线程 MainLooper 和一般 Looper 的异同?
android·面试
洋不写bug7 小时前
数据库的创建,查看,修改,删除,字符集编码和校验操作
android·数据库·adb
2501_915909067 小时前
iOS App 上架全流程详解:证书配置、打包上传、审核技巧与跨平台上架工具 开心上架 实践
android·ios·小程序·https·uni-app·iphone·webview