当前位置: 代码迷 >> 综合 >> 安卓应用程序的启动流程(源码分析)
  详细解决方案

安卓应用程序的启动流程(源码分析)

热度:49   发布时间:2023-10-19 21:17:44.0
> #### ActivityManagerService下的systemReady方法如下:
public void systemReady(final Runnable goingCallback) {
...
// 调用了ActivityStack中的resumeTopActivityLocked去启动Activity
mMainStack.resumeTopActivityLocked(null);
}
> #### ActivityStack中的resumeTopActivityLocked方法如下:
final boolean resumeTopActivityLocked(ActivityRecord prev) {
// 找到第一个当前没有关闭的Activity, 系统刚刚系统没有任何Activity执行, 所以next为null
        ActivityRecord next = topRunningActivityLocked(null);
        // Remember how we'll process this pause/resume situation, and ensure
        // that the state is reset however we wind up proceeding.
        final boolean userLeaving = mUserLeaving;
        mUserLeaving = false;
        if (next == null) {
            // There are no more activities!  Let's just start up the
            // Launcher...
            if (mMainStack) {
// 开启Launcher应用的第一个Activity界面.
                return mService.startHomeActivityLocked();
            }
        }
}
> #### home界面显示, 这时Android系统启动完毕. 进入到待机画面.
  相关解决方案