Introduction
Through the previous two articles:
We have a general understanding of Android, how to build an Android environment and simply write a HelloWorld program, and know what folders and files are included in an Android project and what the corresponding role is. This article will stand at the top level-architecture, see Android. I began to say that this series for 0 basic people and I started from 0 to follow this step to learn, talk about the architecture is a bit gladiators arm pavement, presumptuous it? I think it is not the case, if the entire Android architecture in the beginning of the understanding of the chest, will not go astray, can well grasp the overall situation. The topics in this article are as follows:
- 1. Intuitive architecture diagram
- 2. Detailed architecture
- 2.1. Linux Kernel
- 2.1. Android Runtime
- 2.3, Libraries
- 2.4. Application Framework
- 2.5, applications
- 3. Summary
1. Intuitive architecture Diagram
The following diagram shows the main components of the Android system:
Figure 1, Android system architecture (from: Android SDK)
It can be seen clearly that the Android system architecture consists of 5 parts: Linux Kernel, Android Runtime, Libraries, Application Framework, applications. The second section will cover these 5 sections in detail.
2. Detailed Architecture
Now we pick up the scalpel to dissect the pieces. In fact, this part of the SDK documentation has done a good job for us, we have to do is take doctrine, and then add their own understanding. Below, the layers are analyzed from the bottom up.
2.1. Linux Kernel
Android based Linux 2.6 provides core system services such as security, memory management, process management, network stacks, and drive models. Linux kernel also acts as an abstraction layer between hardware and software, which hides specific hardware details and provides a unified service for the upper layer.
If you learn the computer network know OSI/RM, you will know that the benefits of layering is to use the services provided below to provide a unified service for the upper layer, shielding the differences between the layers and the following layers, when the layer and the following layers have changed will not affect the upper level. In other words, each layer provides a fixed sap (Service Access point), which can be said to be high cohesion and low-coupling.
If you're just doing app development, there's no need to get into the Linux kernel layer.
2.2. Android Runtime
Android contains a collection of core libraries that provide most of the functionality available in the core class library of the Java programming language. Each Android application is an instance of a Dalvik virtual machine that runs in their own process. Dalvik virtual machines are designed to efficiently run multiple virtual machines on a single device. The Dalvik virtual machine executable file format is. The Dex,dex format is a compression format designed for Dalvik and is suitable for systems with limited memory and processor speed.
Most virtual machines, including JVMs, are stack-based, while Dalvik virtual machines are register-based. Both architectures have pros and cons, and generally, stack-based machines require more instructions, and register-based machine instructions are larger. DX is a set of tools that convert Java. class to. dex format. A DEX file typically has more than one. Class. Since Dex has to be optimized, it will increase the file size by 1-4 times, ending with Odex.
Dalvik virtual machines rely on the Linux kernel to provide basic functionality, such as threading and underlying memory management.
2.3, Libraries
Android consists of a collection of C + + libraries that are used by various components of the Android system. These features are exposed to developers through the Android application framework (application framework). Some of the core libraries are listed below:
- System C Library -BSD derivative of standard C system library (LIBC), tuned to embedded Linux based devices
- Media Library -Opencore based on PacketVideo. These libraries support the playback and recording of many popular audio and video formats, as well as still image files, including MPEG4, H, MP3, AAC, AMR, JPG, PNG
- Interface Management --manage access to display subsystems and seamlessly combine multiple applications in two-and three-dimensional graphics layers
- Libwebcore-a modern web browser engine that drives Android browsers and embedded web views
- SGL--Basic 2D graphics engine
- 3D Library --based on the implementation of OpenGL ES 1.0 APIs. Library uses hardware 3D acceleration or contains highly optimized 3D software gratings
- FreeType --bitmap and vector font rendering
- SQLite -a powerful and lightweight relational database engine that all applications can use
2.4. Application Framework
By providing an open development platform, Android enables developers to develop extremely rich and innovative applications. Developers are free to take advantage of device hardware, access location information, run background services, set alarms, add notifications to the status bar, and much more.
Developers can fully use the framework APIs used by the core application. The architecture of an application is designed to simplify the reuse of components, and any application can publish his functionality and any other application can use these features (subject to the security restrictions enforced by the framework). This mechanism allows the user to replace a component.
All applications are actually a set of services and systems, including:
- View--a rich, extensible collection of views that can be used to build an application. Includes lists, grids, text boxes, buttons, and even inline web browsers
- content Providers-enables applications to access data from other applications (such as newsletters) or share their own data
- Resource Manager (Resource Manager)-provides access to non-code resources such as localized strings, graphics, and layout files
- Notification Manager (
Notification Manager )--Enables all applications to display a custom warning in the status bar
- Activity Manager (
Activity Manager )--manages the application lifecycle and provides a common navigation fallback function
2.5, Applications
Android assembles a collection of core applications, including email clients, SMS programs, calendars, maps, browsers, contacts, and other settings. All applications are written in the Java programming language. A richer application awaits us to develop!
3. Summary
From the above we know that Android architecture is layered, very clear, and the division of labor is clear. Android itself is a set of software stacks (software stack), or "Software overlay Architecture", which is divided into three layers: operating systems, middleware, applications. From the above we also see the power of open source, a familiar open source software here to contribute their own strength.
Now that we have an overall understanding of the Android system architecture, I'll use an example to get a sense of it, but given this series of people who want the 0 foundation to be able to understand, before introducing the example, we will introduce the principles and terminology of the Android application. May need several to introduce. Please pay attention!
Android Development Tour 3:android Architecture