Android Application startup process

Source: Internet
Author: User

Reprint: http://www.51testing.com/html/34/n-3725434.html
? Once you have a basic understanding of the whole, then look at the details and talk about AndroidApplication Start-up ProcessA lot articleAre all kinds of source code classes and methods of a bunch of call relationships, such an article even look 100 times, but also just foggy. Source to see, but it is best not to fall into the details of the source code, can not extricate themselves.  Here stand on the basis of predecessors to do a summary. Before the application start-up process, you need to understand the Android system start-up process, because the application start is inseparable from the system processing. Android System Start-up process1.BootLoader boot the kernel and init process; The 2.init process splits a daemon, such as Android Debug Damon,usb Damon, which handles some hardware-related interfaces; The 3.init process starts a zygote process  The zygote process initializes the first VM and pre-loads the framework and some common resources. The zygote process will open a socket interface to listen for requests.  Once the request is received, Zygote will hatch a new VM based on its pre-loaded VM and create a new process. 4. After starting zygote, the init process starts the runtime process. Zygote will hatch a super management process-system Server.  System Server launches services for all core systems, such as activity Manager service and hardware-related service. 5. This is the time to start preparing to start its first AppThe process-home the process. Android system has been started, some core services have been started, and then launch the Launcher application, then when to start the application process? when was the app process created? The answer is to be created when needed. If an app (mostly launcher) invokes a page in the app, if the target process does not exist, a new process is created and started. Application START ProcessBefore we say application start the process, look at one of the previous flowchart: When the app starts the flow analysis process, you can look at the flowchart above.  Click on the desktop icon and then call the StartActivity (Intent Intent) method, which will eventually call Activitymanagerservice through the binder IPC, which is referred to as AMS.  AMS does the following: it will eventually collect the intent object's pointing information through the Packagemanager Resolveintent () method (the middle will go through many classes, method calls).  Verify that the user has sufficient permissions to invoke the target activity through the granturipermissionlocked () method, and that if the query Processrecord exists, AMS creates a new process to instantiate the target activity. The next step is to create the app process. creation of the app processCall the Startprocesslocked () method to create a new process through the socket channel described above to pass parameters to the zygote process, zygote process hatch itself, and call Zygoteinit.main ()  method to instantiate the Activitythread object and eventually return the PID of the new process.  Activitythread calls the Looper.prepare () and Looper.loop () methods in turn to turn on the message loop. The process has been created at this time, but how does it relate to the application of the application itself? Bindings for ApplicationCall the Bindapplication () method in Activitythread to send a bind_application message to the message queue.  The previous binding message is processed by the Handleapplication () method, and the Makeapplication () method is called to load the application class into memory. The approximate process is as follows, if you need to do some special processing, or you need to go deep into the source, find the point that you can handle, some custom processing.

Android application startup process

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.