Android Development Components

Source: Internet
Author: User
Tags map class

Each application has its own separate run sandbox (grant access to application code)

    • The Android operating system is a multi-user Linux system, and each of these applications is a standalone user.
    • Each application is assigned a unique Linux user ID, and the system sets permissions for all files of an application, so only the user ID assigned to the application can access them.
    • Each process has its host virtual machine (VM), so the code for one application runs independently of other applications.
    • Each application runs in its own Linux process. This process is closed when no component is called or if the system needs to reclaim memory for other applications.

Components of the application

  Activity

 An activity provides a separate interface for a user interaction, and each application is composed of multiple activity

It provides a screen for the user to interact with the task. For example, make a phone call, take a photo, send an email. or view the map. Each activity is assigned a window. In this window, you can draw the content of user interaction. This window usually fills the screen, but it may be smaller than the screen and floats on top of other windows.

Service (Serviced components)

A service is a component that runs in the background. It is used to perform time-consuming operations or remote processes. A service does not provide an interface for user interaction.

For example, when a user is using another program, a service may be playing music or fetching data over the network, which does not block the user's interaction with the activity. Other components, such as an activity, can start a service and let it run or bind to it, and can interact with it after binding.

Content provider (contents provide components)

  A content provider is responsible for managing the data sharing set of the application.

You can store data through file systems, SQLite databases, websites, or other persistent storage locations that your application can access. With content provider, other applications can query or even modify your data (if the content provider allows them to do so). For example, the Android system provides a content provider to manage contact information. Similarly, any program that has the appropriate permissions can query the content provider (for example ContactsContract.Data ) to read and write information about someone.

Broadcast receiver (broadcast receiving component)

  broadcast receiver is a component that responds to system-wide broadcasts. Many broadcasts emanate from the system itself. -for example, the notification screen has been turned off, the battery is low, and the photo is being photographed. Applications can also initiate broadcasts. -for example, notifying other programs that some data has been downloaded to the device and available for use. Although the broadcast does not provide a user interface, they can also create a status bar notification to alert the user that a broadcast event has occurred. Even more so, a broadcast is just a "gateway" to other components and tries to do a little bit of work. For example, it might initiate a service and perform the work related to this broadcast event through the service.

Activating components

-activitie, service, and broadcast receiver-are activated by an asynchronous message called Intent . Intent binds separate components at run time (you can think of them as messages that request actions from other components), whether they belong to you or any other program.

For activity and service, a intent defines the actions that will be performed

For broadcast receiver, intent simply defines the announcements that need to be broadcast.

Content provider, not activated with intent. Relatively, it is activated by a ContentResolver request that initiates a point to it.

This content resolver master the direct transaction of all content provider, so the component that executes the transaction with this provider does not need to execute directly but to invoke the ContentResolver method of this object. It places an abstraction layer between the content provider and the component request information (for security).

there are different ways to activate various types of components:
    • You can start an activity (or let it do some new work) by passing a Intent given startActivity() or startActivityForResult() (when you want an activity to return a result for you).
    • You can start a service (or send a new instruction to a running service) by passing a Intent given startService() . Or you can bind a service by passing a Intent given bindService() .
    • You can initialize a broadcast by passing one Intent to some method like sendBroadcast() , sendOrderedBroadcast() or sendStickyBroadcast() .
    • You can have content provider perform a query operation by invoking ContentResolver the query() method.
configuration file

Before the Android system can start a program component, the system must read the program's AndroidManifest.xml file

Your program must declare all of its components in this file. In addition to declaring program components, this configuration file does some other work, such as:

    • Determine which user rights The program requires, such as network access or reading the user's contacts.
    • Declare the minimum API level required by the program to refer to which APIs are used by the program.
    • Declares the hardware and software features that the program uses or requires, such as cameras, Bluetooth services, or multi-touch screens.
    • The program requires a linked API class library (other than the Android framework API) such as the Google map class library.
    • Other
Intent

Intent's best place is actually its action concept, using action, you can simply describe the action you want to perform (and you can specify what data you want to put on the action) and allow the system to find the component that can perform the action on the device and start it. If more than one component can perform this action, it is up to the user to decide which to execute.

Android Development 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.