Android10.0(一)|Android10.0(一) Activity启动流程 源码简析
前言 熟悉Activity的启动流程和运行原理是一个合格的Android应用开发人员所应该具备的基本素质,下面在Android10.0 aosp基础上进行梳理。
谨以此记录下学习流程,欢迎广大博友交流指正。是时候提高一波了。。。
code
文章图片
代码下载 基于Ubantu16.04,国内使用清华mirror下载,如下:
wget -c https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar # 下载初始化包
tar xf aosp-latest.tar # 解压
cd AOSP # 解压得到的 AOSP 工程目录
repo sync # 正常同步一遍即可得到完整目录
代码阅读器 推荐 IntelliJ IDEA
相关类简介
1.Launcher
Default launcher application.
2.BaseDraggingActivity
Extension of BaseActivity allowing support for drag-n-drop.
3.Instrumentation
Base class for implementing application instrumentation code. When running with instrumentation turned on, this class will be instantiated for you before any of the application code, allowing you to monitor all of the interaction the system has with the application. An Instrumentation implementation is described to the system through an AndroidManifest.xml’s
4.ActivityTaskManagerService
System service for managing activities and their containers (task, stacks, displays,… ).
5.ActivityStarter
Controller for interpreting how and then launching an activity.
6.RootActivityContainer
This class is mostly temporary to separate things out of ActivityStackSupervisor.java. The intention is to have this merged with RootWindowContainer.java as part of unifying the hierarchy.
7.ActivityStack
State and management of a single stack of activities.
8.ActivityStackSupervisor
This class has become a dumping ground. Let’s
Move things relating to the hierarchy to RootWindowContainer
Move things relating to activity life cycles to maybe a new class called ActivityLifeCycler
Move interface things to ActivityTaskManagerService.
All other little things to other files.
9.ProcessList
Activity manager code dealing with processes.
10.ZygoteProcess
Maintains communication state with the zygote processes. This class is responsible for the sockets opened to the zygotes and for starting processes on behalf of the {@link android.os.Process} class.
11.LocalSocket
Creates a (non-server) socket in the UNIX-domain namespace. The interface here is not entirely unlike that of java.net.Socket. This class and the streams returned from it may be used from multiple threads.
12.ActivityThread
This manages the execution of the main thread in an application process, scheduling and executing activities, broadcasts, and other operations on it as the activity manager requests.
13.LaunchActivityItem
Request to launch an activity.
启动流程
1.从桌面点击应用图标到Activity所在进程启动
文章图片
2.Activity启动
文章图片
至此我们看到了熟悉的Activity的onCreate(),下面将执行Activity的生命周期方法。
【Android10.0(一)|Android10.0(一) Activity启动流程 源码简析】系列文章
Android10.0(一) Activity启动流程 源码简析
Android10.0(二) WMS启动流程 源码简析
推荐阅读
- 一个人的旅行,三亚
- 一个小故事,我的思考。
- 《真与假的困惑》???|《真与假的困惑》??? ——致良知是一种伟大的力量
- 开学第一天(下)
- 一个人的碎碎念
- 2018年11月19日|2018年11月19日 星期一 亲子日记第144篇
- 遇到一哭二闹三打滚的孩子,怎么办┃山伯教育
- 第326天
- Y房东的后半生14
- 奔向你的城市