Startup Process of the Android sub-Activity component in the process & amp; Sub-Activity component in the new process

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.