Android App composition

Source: Internet
Author: User

An Android application is typically comprised of the following 4 components:

    • Activities (activity)
    • Intentions (Intent)
    • Services (Service)
    • Content provider (contents Provider)

These 4 components are the basis for Android app changes, but not every Android application must contain this 4 component, except the activity is the necessary component, the rest of the components are optional.

Activity

Activity is one of the most basic building blocks in an Android application, where an activity is usually a separate screen. Each activity is implemented as a separate class and is inherited from the activity's base class. The activity class will display a user interface consisting of several views controls and respond to the event. Most applications will contain multiple screens.

Intent

The intent class is used to describe what an application wants to do. It is a run-time binding mechanism used to connect two different components. With intent, an application can express some kind of request or intention to Android, and Android chooses the appropriate component to respond to the desired content.

The two classes associated with intent are intentfilter and Intentreceiver respectively. When intent requests an action, Intentfilter is used to describe which intent an activity or broadcast receiver can manipulate. Intentreceiver enables the application to respond to external events.

The intent has two most important parts: the data corresponding to the action and the action. Typical action types are: Active viewing (view), Selection (Pick), editing (edit), and so on, while the data corresponding to the action is represented in the form of a URI.

Service

A service is a section of a life cycle, without a user-interface program. It runs in the background and can interact with it. It is similar to the activity level, but needs to be called through an activity.

A good example is a media player that is playing songs from a playlist. In a media player application, there should be multiple activity, allowing the user to select songs and play songs. However, there is no activity associated with the music replay because the user will of course think that the music should still be playing when navigating to other screens. In this example, the Media Player activity uses context.startservice () to start a service so that it can keep the music playing in the background. At the same time, the system will keep the service running until the end of the service run.

Content Provider

Android system applications can save their data to files, SQL databases, or even any valid device. Content provider provides a way to share data among multiple applications. Content provider is useful when you want to share your app data with other apps. A content provider class implements a standard set of methods that enable other applications to save or read the various data types that are processed by this content provider.

Android App composition

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.