熟悉Activity的启动流程和运行原理是一个合格的Android应用开发人员所应该具备的基本素质,下面在Android10.0 aosp基础上进行梳理。
谨以此记录下学习流程,欢迎广大博友交流指正。是时候提高一波了。。。
基于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
Default launcher application.
Extension of BaseActivity allowing support for drag-n-drop.
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
System service for managing activities and their containers (task, stacks, displays,… ).
Controller for interpreting how and then launching an activity.
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.
State and management of a single stack of activities.
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.
Activity manager code dealing with processes.
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.
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.
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.
Request to launch an activity.
至此我们看到了熟悉的Activity的onCreate(),下面将执行Activity的生命周期方法。
系列文章
Android10.0(一) Activity启动流程 源码简析
Android10.0(二) WMS启动流程 源码简析