1. Startup Process of the Child Activity component in the process
When the Android Activity component is started.
There are two main tasks. One is that you do not need to create a new task stack, and the other is that you do not need to create new processes and subthreads.
The Code 1st is shown in the following code:
~ /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;}......}
Point 2nd is embodied in the following code. Now the sub-Activity process and its sub-thread are available.
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. Startup Process of the Child Activity component in the new process
And the Startup Process of the Android Activity component. The code is shown above. You also need to create new processes and subthreads.