In-depth analysis of Android Application Components

Source: Internet
Author: User
Tags sqlite database

Android applications are composed of scattered and associated components and bound together by a project manifest. In manifest, each component and its role are described. There are six components that are the foundation of Android applications:

Activitiy (activity)

The display layer of the application. Activity is a visualized and interactive user interface. Its features are as follows:

  • An application may have 1. N activities. Each activity is independent of each other and is an extension of the activity class;
  • Generally, an activity is marked as the first activity after startup by the application program;
  • By default, an activity is assigned with a printable window, which usually fills the entire screen;
  • Activity uses views to build the UI to display information and respond to user behaviors.

The visible content of a window is provided by multi-layer views (objects derived from the view base class). Each view control in a window is a specific rectangular space. The parent view contains and organizes the layout of their child views. The leaf view (at the bottom of the hierarchy) controls and responds to user operations in the drawn rectangular space. In this way, the user can send intent requests through the activity view. A view hierarchy is placed in the activity window through the activity. setcontentview () method. The content view is the root object of the view hierarchy.

 

Service)

A service is a service that is invisible to users and runs in the background without time restrictions. It updates data sources and visible activities, and triggers notifications. Its features are as follows:

  • All services are implemented by subclasses of basic services;
  • It is often used to perform processing that requires continuous operation;
  • You can connect (BIND) Other continuously running services (if it is not yet running and start the service) and communicate with the service through the APIS exposed by the Service.

Services run in the main thread of an application like activity and other components. To avoid blocking other components or user interfaces, they often generate another thread to process time-consuming tasks.

 

Broadcast receivers (broadcast receiver)

Consumer of intent broadcast ". By creating and registering a broadcast receiver, an application can listen to intent broadcast that meets specific conditions. Broadcast receiver automatically starts your Android Application to respond to the new intent. Broadcast receiver is an ideal means for event drivers. The broadcast receiver does not display the user interface. However, they may initiate an activity to respond to received information or use icationicationmanager to notify users. Notifications can be noticed in various ways-backlight flashing, vibrating devices, playing sounds, and so on. They are usually placed in the status bar. You can open a specific icon in the status bar to get the message.

 

Content Providers)

Provides shared data storage. The content provider is used to manage and share applications. Content Provider is the preferred method for data sharing between applications. This means that you can configure your own content provider to access other applications or the content provider exposed by other applications to access their data. The Android device contains several content providers to access useful databases such as contact information. The data can be stored in a file system, in an SQLite database, or in any other identifiable way. Contentprovider is derived from the contentprovider base class. It uses methods of other applications to retrieve and store its controllable data types to perform Standard settings. However, applications do not directly call these methods. Instead, they use the contentresolver object and call its method. A contentresolver can interact with any contentprovider, which works with the provider to manage communication between any process.

 

Intents)

A simple message transmission framework. With intent, You can broadcast messages throughout the system or send specific activities or services to execute your action intent. The system will decide which (some) target to execute the appropriate behavior.

 

Notifications)

User notification framework. Notification is used to prompt users without focus or interrupting their current activity. They are the first choice for service or broadcast receiver to get user attention. For example, when a device receives a text message or an external call, it will notify you by flashing, making a voice, displaying an icon, or displaying a dialog box.

One of the main features of Android is that an application can use the elements of other applications (these application licenses. For example, content provider or service-Your and others are third-party.

For this purpose, the system must be able to process any part of its needs when starting the application and convert that part into a Java object. Therefore, unlike most applications on other systems, Android applications do not have a single entry point to process all the content in the application (for example, there is no main () function ). The component mentioned above is an important part of the application's instantiation and running needs.

 

 

References: http://developer.51cto.com/art/201001/180361.htm

Http://developer.android.com/guide/topics/fundamentals.html

Related Article

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.