Android system launch frame, activity interface display process detailed

Source: Internet
Author: User

I. Android system framework

Android's system architecture, like its operating system, employs a layered architecture. From the architecture diagram, Android is divided into four tiers, from the high-level to the lower layer, which are application layer, application framework layer, system run-level and Linux core. The theft chart is as follows:

Specific features of each layer are described below:

(1) Application layer

The tier provides core application packages such as e-mail, text messages, calendars, maps, browser and contact management. At the same time, developers can use the Java language to design and write their own applications, which are equal and friendly with those core applications.

(2) Application framework layer

This layer is the basis for Android app development, and most of the time developers are dealing with her. The application framework layer includes the Activity Manager, window Manager, content provider, view system, Package Manager, Phone manager, resource manager, Location manager, Notification Manager, and XMPP Services 10 sections. On the Android platform, developers have full access to the API framework used by the core application. Also, any application can publish its own module of functionality, while other applications can use these published function modules. Based on this reuse mechanism, users can easily replace the various application components of the platform itself.

(3) system library and Android runtime

The system library consists of nine subsystems, layer management, Media Library, SQLite, Openglestate, FreeType, WebKit, SGL, SSL, and libc. The Android runtime includes both the core library and the Dalvik virtual machine, which are compatible with the function functions that most Java languages need to invoke, and the core libraries of Android, such as Android.os, Android.net, Android.media, and so on. The latter is a register-based Java Virtual machine,Dalvik virtual machine is to complete the life cycle management, stack management, thread management, security and exception management, garbage collection and other important functions.

(4) Linux kernel

Android Core system services rely on Linux2.6 cores such as security, memory management, process management, network protocol stacks, and drive models. The Linux kernel is also an abstraction layer for hardware and software stacks. Drivers: Display drivers, camera drivers, keyboard drivers,WiFi drivers,audio drivers,flash memory drivers,Binder (IPC) drivers, power management, and more.

Android's system architecture uses a layered architecture that is structured and structured to work together. Therefore, if you want to engage in Android application development, research and research Android application framework and Application layer, if you want to engage in Android system development, that research under the Android system library and Android runtime, if you want to engage in Android Drive development, Then try to look at the Android Linux kernel. The following describes the Android system startup process and the activity interface display process, respectively:

Second, the Android system startup process

As we all know, in Linux, its start-up can be categorized as a few processes: boot loader--> initializes the kernel and creates the INIT process--and performs other startup items according to the inittable file-->

Thus, when the kernel is initialized, a fairly important ancestor process is initiated, that is, the init process, where all processes in Linux are directly or indirectly forked by the INIT process. For Android, the previous process is the same:

(1) When the init process is created, it will fork out a zygote process, which is the parent process of all Java processes. We know that Linux is based on C, and Android is Java-based (and of course the bottom is C);

(2) then fork out a zygote Java process that is used to fork out other processes. When the zygote (hatching process) is initialized, it will fork out the system server process, which is a very important one in the entire Android process, the status and Zygote equivalent, it belongs to the application framework layer, All the services in Android, such as AMS, Windowsmanager, Packagemanagerservice and so on, are all made up of this systemserver fork. So its status is evident;

(3) When the system server process is turned on, the AMS is initialized, and the service library of the local system is loaded, the system context is created, the Activitythread is created, various services are opened, and so on. After this, it will open the System Launcher program, complete the system interface loading and display;

(4) When the system starts, when we click on the screen, the two electrodes of the touchscreen are connected together, creating a voltage and passing the XY coordinates of the current press point to the Android system via the corresponding drive. When the system obtains the XY value, it will make a judgment on the range of the press point, and if it is determined that the pressing point is in the range of an app icon or button, the operating system will assume that the user has clicked on the object and started the corresponding listener. And when the system determines that we click on the app icon, the app is started by launcher;

(5) When starting, the launcher process will use binder to issue startactivity request to AMS (Activity Manager Server);

(6) After receiving the request, AMS will send a request to the zygote process through the socket to create the process;

(7) The zygote process will fork out the new sub-process (app process);

(8) Then the app process will then initiate a request to AMS, AMS received after a series of preparatory work to return the request;

(9) When the app process receives the request returned by AMS, it uses handler to send the launch_activity message to the main thread (that is, the UI thread);

Note: The main thread (also known as Activitythread) has a main () method, which is the real entrance of the app, and when the app starts, it launches the Main method in Activitythread. In the main method, the system uses Looper.preparemainlooper () to create the Looper and MessageQueue of the main thread and to turn on the message loop through Looper.loop.

(10) The main thread will create the target activity after receiving the message, and callback OnCreate ()/onstart ()/onresume () and so on, the UI rendering will be able to see the app main interface after the end.

Three, the interface display process

Android system launch frame, activity interface display process detailed

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.