Android adopts a hierarchical architecture like its operating system. From the structural diagram, Android is divided into four layers: application layer, application framework layer, system Runtime Library layer, and Linux core layer.
Android Architecture
1. Applications
Android is released together with a series of core application packages, including email clients, SMS Short Message programs, calendars, maps, browsers, and contact management programs. All applications are written in Java.
2. Application Framework
Developers can also fully access the API framework used by core applications. The architecture design of this application simplifies Component Reuse. Any application can publish its functional blocks and any other
Applications can use the feature blocks they publish (but they must comply with the security restrictions of the Framework ). Similarly, this application reuse mechanism allows you to easily replace program components.
A series of services and systems are hidden behind each application, including;
* Rich and scalable views can be used to build applications, including lists, grids, and text boxes ), button (buttons), or even an embedded web browser.
* Content providers allow applications to access data of another application (such as the contact database) or share their own data.
* Resource manager provides access to non-code resources, such as local strings, images, and layout files ).
* Notification Manager allows applications to display custom prompts in the status bar.
* Activity manager is used to manage the application lifecycle and provides common navigation rollback functions.
For more details and how to write an application from scratch, see how to write an Android Application.
3. System Runtime Library
1) Library
Android contains some C/C ++ libraries that can be used by different components in the Android system. They provide services to developers through the Android Application Framework. The following are some core databases:
* System C library-a standard C system function library (libc) inherited from BSD, which is specially customized for Embedded Linux devices.
* Media library-Based on packetvideo opencore. This Library supports multiple common audio and video formats for playback and recording, and supports static image files. The encoding formats include MPEG4, H.264, MP3, AAC, Amr, JPG, and PNG.
* Surface Manager-manages the display subsystem and provides seamless integration of 2D and 3D layers for multiple applications.
* Libwebcore-the latest web browser engine that supports Android browsers and an embedded Web View.
* SGL-underlying 2D graphics engine
* 3D libraries-implemented based on OpenGL ES 1.0 APIs. This library can use hardware 3D acceleration (if available) or highly optimized 3D soft acceleration.
* FreeType-bitmap and Vector Fonts.
* SQLite-a lightweight relational database engine that is available to all applications and has powerful functionality.
2) Android Runtime Library
Android includes a core library that provides most of the functions of the core library of Java programming language.
Every android application runs in its own process and has an independent Dalvik Virtual Machine instance. Dalvik is designed as a device that can run multiple
Virtual System.
Dalvik executable files executed by the Dalvik Virtual Machine (. Dex), which are optimized for small memory usage. At the same time, the virtual machine is register-based, and all classes are compiled through Java
The interpreter is compiled and then converted to the. Dex format by using the "dx" tool in the SDK, which is executed by the virtual machine.
The Dalvik virtual machine depends on some features of the Linux kernel, such as the thread mechanism and the underlying memory management mechanism.
4. Linux Kernel
Android core system services depend on the Linux 2.6 kernel, such as security, memory management, process management, network protocol stack and driver model. The Linux kernel is also an abstraction layer between the hardware and software stacks.