This article describes the architecture of Android, the composition of Android applications and the logic of Android applications.
1. Android Architecture
Android's software hierarchy includes an operating system, middleware, and applications. Its software hierarchy can be divided from top to bottom:
- Application
- Application Framework
- runtime environments for various libraries and Android
- Operating system Layer
Applications: Written in the Java language and designed for user interface interaction design. Android itself provides many core applications such as desktops, contacts, phones, browsers, and so on.
Application framework: Provides the system's API for the application. With Android's application framework, developers can reuse a variety of components and services. Framework components of the application:
- UI components: Include lists, text boxes, buttons, and other UI components that are part of the user's visual.
- Content Providers: Provides a mechanism for application programs to implement data access and sharing.
- Notification Manager: Allows the application to display its own warning message on the status bar, such as displaying a new text message and prompting for battery information.
- Activity Manager: Manages the life cycle of an application and provides a mechanism for application page exit.
Android Library and run-time environment
Android contains some core C + + libraries that can be used by various components of the system through JNI technology.
These libraries include:
- System C Library: standard C library from BSD inheritance.
- Media Library: Includes a variety of commonly used audio, video format playback and recording. At the same time support static image files, support MPEG4,MP3,AAC,JPG,PNG,H.264,AMR and other encoding formats.
- Surface Manager: Manages the display subsystem and provides seamless integration of 3D to multiple applications.
- Libwebcore: Browser engine.
- SGL: The underlying 2D graphics engine.
- 3D Librarie: Provides 3D acceleration.
- FreeType: Provides font display of bit bitmaps and vectors.
- SQLite: Database application.
Android includes a core library that provides most of the functionality of the Java language Core library.
Each Android application runs within its own process space and has a standalone Dalvik virtual machine implementation. The Dalvik is designed as a device that can run multiple virtual systems simultaneously and efficiently. Dalvik virtual machines rely on some features of the Linux kernel, such as thread scheduling, memory management.
2. Android App composition
The Android program consists of the following four parts:
- Activity
- Broadcast Intent Receiver
- Server
- Content Provider
Activity, typically represents a screen of a mobile phone, equivalent to a browser page. Add a view to the activity to implement the application interface and user interaction. An application typically consists of multiple activity, which can jump to and from one another, making it possible to transfer data between pages. Each activity has its own life cycle.
Intent Receiver,intent is an abstract description of the operation that will be performed. By intent, you can achieve jumps between activity and activity. The most important component of intent is the intent action and the data of the action. A class associated with intent is called intent Filters. It is used to describe what operations the intent can use to handle.
Broadcast Intent Receiver, used in response to external events. Broadcastreceiver cannot generate UI, so it is not visible to the user.
Service that runs the application in the background.
Content Provider: A content Provider provides a standard set of interfaces that enable applications to save or read various data types of content Provider. An application can expose its own data through it. For external applications, it does not need to care about how the data is stored, where it can be accessed only through the R interface provided by the content provide. This, of course, involves permission issues with data access.
3. Android Engineering File composition
Android was developed using Eclipse+adt.
The project documents include:
- Source files: Code written in the Java language, including implementations of various activities.
- R.java: Generated automatically by eclipse, containing the resource ID used by the application.
- Android library:android library files.
- Assets: Place multimedia files and so on.
- Res: Resource files, labels, animations, colors, etc. required by the application.
- drawable: Picture Resources
- Layout: Describes how the activity is laid out.
- Values: defining strings, colors, etc.
- Android Manifest.xml: The application's configuration file. Declare the name of the application in the file, use the activity,service,receive, permissions, and so on.
Android Application Architecture