1、子Activity组件在进程内的启动过程
在Android Activity组件的启动过程http://blog.csdn.net/jltxgcy/article/details/35984557一文中,我们已经详细分析了Activity的启动过程,对于子Activity组件在进程内的启动过程,我们只分析它们之间的不同。
主要是2处,1是不需要创建新的任务栈,2是不需要创建新进程和子线程。
第1点,体现在如下代码上:
~/Android/frameworks/base/services/java/com/android/server/am
----ActivityStack.java
public class ActivityStack { ...... final int startActivityUncheckedLocked(ActivityRecord r, ActivityRecord sourceRecord, Uri[] grantedUriPermissions, int grantedMode, boolean onlyIfNeeded, boolean doResume) { final Intent intent = r.intent; final int callingUid = r.launchedFromUid; int launchFlags = intent.getFlags(); ...... if (sourceRecord == null) { ...... } else if (sourceRecord.launchMode == ActivityInfo.LAUNCH_SINGLE_INSTANCE) { ...... } else if (r.launchMode == ActivityInfo.LAUNCH_SINGLE_INSTANCE ...... } if (r.resultTo != null && (launchFlags&Intent.FLAG_ACTIVITY_NEW_TASK) != 0) { ...... } boolean addingToTask = false; ........ boolean newTask = false; // Should this be considered a new task? if (r.resultTo == null && !addingToTask && (launchFlags&Intent.FLAG_ACTIVITY_NEW_TASK) != 0) { ...... } else if (sourceRecord != null) { ...... // An existing activity is starting this new activity, so we want // to keep the new one in the same task as the one that is starting // it. r.task = sourceRecord.task; ...... } else { ...... } ...... startActivityLocked(r, newTask, doResume); return START_SUCCESS; } ...... }
第2点,体现在如下代码上,此时已经有了子Activity进程和它的子线程了。
private final void startSpecificActivityLocked(ActivityRecord r, boolean andResume, boolean checkConfig) { // Is this activity's application already running? ProcessRecord app = mService.getProcessRecordLocked(r.processName, r.info.applicationInfo.uid); ..... if (app != null && app.thread != null) { try { realStartActivityLocked(r, app, andResume, checkConfig); return; } catch (RemoteException e) { ..... } ..... } ...... }
2、子Activity组件在新进程中的启动过程
和Android Activity组件的启动过程http://blog.csdn.net/jltxgcy/article/details/35984557一文中,主要有一个区别,不需要创建新的任务栈。代码如上面所示。还需要创建新进程和子线程。
Android 子Activity组件在进程内的启动过程 && 子Activity组件在新进程中的启动过程,布布扣,bubuko.com
时间: 2024-10-21 19:54:23