Android Application Framework-Components

Source: Internet
Author: User

The content of this article according to individual self-study collation records, understanding of the inappropriate, I hope you criticize correct, we learn from each other, write learning induction, blogging is a good habit, hope to persist.
The Android system framework was introduced in the previous article, primarily to give you a clear understanding of the internal hierarchy of Android and the basis for developing Android programs. What does it take to develop an Android application after understanding the structure of the system, this article is mainly about the basic component system of Android program development.

The core of Android application framework:

Since Android applications are also developed using the MVC concept, it is necessary to understand the next division of work modules, the Android application framework contains four core elements:
  activity: is the interaction and Execution unit of the program, which mainly controls the interface, can be understood as (part of Controller), and manages the life cycle of the view.
  Intent (Intent): is the foundation for building loose coupling, which supports jumping from one page to another.
  View: the interface presented to the user, showing various information, various operations, the logic behind, execution to the controller.
  task: A set of activities that spans multiple apps. The concept of task is abstract, because we usually do not directly contact, it is different from the traditional program of a functional module is a task (conceptually there are similar places, there are differences, to deepen understanding).
The following example deepens the understanding diagram. 1

When we open an APP on the phone interface, the system creates a task (Task), opens an activity, and turns on an interface (View), Intent (Intent) is responsible for implementing the function of jumping to the right interface from the interface on the left side of Figure 1. When the app needs to send a prompt text message to the user (or push new content in the notification bar, or open another installed APP), this process is the function of the task, which contacts multiple activities/applications and creates multiple independent processes and heaps.
About multi-tasking execution process:

When the "Next Interface" button is pressed, the right arrow action is performed, and the return key is pressed to perform the left arrow action.
Stack changes for a single-task execution process:
Left: From bottom to top, add to the right of the stack: from top down, exit the stack sequentially

Stack changes for multi-tasking processes:

Left: From bottom to top, add to the right of the stack: from top down, exit the stack sequentially

Also, be aware of the Activity's Langchmode, which will be described later.

Four components of the Android system:
The Android System application framework is generally considered to contain four components: activity, service, broadcast receiver (broadcast receiver), content provider (Provider). They follow a uniform standard, each component implements a variety of standard interfaces that meet its functions, each with its own special functions, can be used alone, and deployed together to achieve a certain need.
Here's a brief introduction to the features of each component:
1. Activity: Completes the interactive task with the user, executes the user action behavior of the interface. The new activity class inherits the activity class of the system, maintains and manages the View control, and implements the management function for the activity life cycle.

Activity life cycle Management diagram. 2

2. Service: Responsible for supporting tasks performed in the background and managing their lifecycle.
Service life cycle Management diagram. 3

You cannot think of a service as a separate process or thread, a relationship that is not equivalent to the process of an application, a complex connection between them, a new thread should be opened and processed using the message association to process its Handler in order to perform time-consuming operations in the service.
3. Broadcast receiver (broadcast receiver): used to receive broadcasts from other applications, enhancing the interactivity of the Android system.
4. Content Provider: The data sharing link of each application in the system, through which the interoperability of data between applications can be realized. It provides four commonly used data operations: Insert (insert), query, UPDATE, delete (delete).

Summarize:
About the above four kinds of components, the article just introduced their basic functions and related concepts, not very comprehensive, inevitably there are omissions and errors, their detailed content also need to be in the actual programming process slowly experience and learning. In the actual application, the general use of various components, so that the application function is complete, so it is very important to master each of the components, I hope that the introduction of the above to help the study. Android application framework is very complex, for beginners, may feel the concept of a lot of confusion, this article takes you from the most basic framework components to learn, to clarify their respective functions.

Android Application Framework-Components

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.