From the source point of view an APK boot process and an activity of the boot process

Source: Internet
Author: User

APK program Running Process

First, Activitythread begins execution from the main () function, calling Preparemainlooper () to create a message queue (MessageQueue) for the UI thread.

A Activitythread object is then created, and an H (Handler) object and a Applicationthread (Binder) object are created in the initialization code of the Activitythread. Where Binder is responsible for receiving IPC calls from the remote AMS, and when the call is received, the message is sent to the message queue via handler, and the main thread of the UI asynchronously extracts the message from the message queue and performs the appropriate actions, such as start, stop, pause, and so on.

The main thread of the UI then calls the Looper.loop () method into the message loop body, which continues to read and process the message from the message queue as it enters.

The specified Activity object is created when Activitythread receives the AMS send start activity. Activity will also create Phonewindow class →decorview class → Create the corresponding view or ViewGroup. Once created, the activity needs to display the created interface to the screen, calling the WindowManager class, which then creates a Viewroot object that actually creates the Viewroot class and the W class, and after the Viewroot object is created, WindowManager then invokes the remote interface provided by the WMS to complete adding a window and displaying it to the screen.

Next, the user begins to operate on the program interface. KEYQ threads constantly store user messages in the queueevent queue, Inputdispatcherthread threads take out messages one by one, and then call the corresponding function in the WMS to process the message. When the WMS discovers that the message belongs to a client window, it calls the corresponding window's W interface.

The W class is a binder that receives the IPC calls from the WMS and passes the call message to Viewroot,viewroot and then passes the message to the UI main thread Activitythread,activitythread parses the message and handles it accordingly. In the client program, the first process of the message is Decorview, if decorview do not want to process a message, you can pass the message to its inner child view or viewgroup, if not processed, passed to Phonewindow, Finally, it is passed on to the activity.

From the source point of view an APK boot process and an activity of the boot process

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.