In order to prepare for the interview, the recent review of the content in the form of a blog to save, convenient for future inquiries
This article refers to Lao Luo's article http://blog.csdn.net/luoshengyang/article/details/6703247 finishing, because the old Luo's article source code is older, this article also refers to the book with the president.
Well, start learning, we're talking about the call to activity startactivity.
The startactivity that invokes the activity is actually internally called Startactivityforresult. and inside Startactivityforresult is called instrumentation execstartactivity. Execstartactivity internally invokes the StartActivity (binder mechanism) of AMS. AMS performs some stack-related work during startactivity (get information about initiating activity Activityrecord, stack creation, check permissions, etc.).
The startactivity call process for AMS is as follows:
----Activitystacksupervisor. startactivitymaywait(direct invocation, no other code): Parses information about the activity that needs to be started from the intent. such as: Package name, class name. The relevant information exists in the Resolveinfo class, and the Activityinfo object is obtained through the class.
----Activitystacksupervisor. startactivitylocked: By passing in the caller parameter (iapplicationthread type, From the activity's startactivity function, start with a function call to get information about the caller's process, save it to the Callerapp (processrecord type) variable, and then create the activity-related information to start. Save to the R (Activityrecord) variable.
----Activitystacksupervisor. startactivityuncheckedlocked: Gets the activity's startup mode, determines whether the activity to start is on top of the stack, gets the activity load stack.
----Activitystack. resumetopactivitieslocked: Ensure that the stack on which the activity is invoked is at the top.
----Activitystack. resumetopactivityinnerlocked: Determines whether the stack on which the activity is to be started is not visible to the current user and does not need to continue if it is not visible, because even if the activity is started, the user cannot see it. You might as well save it first, and then start again the next time it's visible. If it is visible, continue execution. Add the activity you want to start to the top of the stack.
----Activitystacksupervisor. startspecificactivitylocked: Mainly related to the activity process to be started. Determine if the process has been run and whether another process has been opened. If no new process is specified, directly with the default process, the realstartactivitylocked is called directly.
----activitystacksupervisor.realstartactivitylocked: A schedulelaunchactivity function that is driven into applicationthread by binder.
After doing this, AMS Applicationthread (is a binder object) through the binder to adjust the schedulelaunchactivity. Applicationthread control the activity life cycle through messaging mechanisms.