Android build block

Source: Internet
Author: User

The android application contains four build blocks:

  • Activity
  • Intent receiver er
  • Service
  • Content Provider
  •  

    1 activity

    In an application, an activity is usually a separate screen. Every activity is implemented as an independent class and inherits from the base class of activity. This activity class will display the user interfaces composed of several views controls and respond to the events.

     

    2 intent and intent Filters

    The intent class is used to describe what an application wants to do. In the description structure of intent, there are two most important parts: the data corresponding to the action and action. Typical action types include main, view, pick, and edit. The data corresponding to the action is represented in Uri format.

    When you navigate forward, activity calls the startactivity (intent myintent) method. Then, the system finds the activity that best matches the intent of myintent in the intentfilter defined in all installed applications. The new activity starts to run after it receives a notification from myintent. When the startactivity method is called, myintent Parsing is triggered.

     

    3 intent Receiver

    When you want your application to respond to an external event, you can use an intent receiver. Intent consumer er is registered in androidmanifest. XML, but you can also use context. registerreceiver () in the Code for registration. When an intent consumer er is triggered, your application does not need to call the intent consumer ER for the request. The system starts your application as needed. Various Applications can also broadcast their own intent Referer to other applications by using context. broadcastintent.

     

    4 Service

    A service has a long life cycle and has no user interface. Activity uses context. startservice () to start a service by using context. bindservice () method, connected to a service. After connecting to a service, we can also communicate with the interface provided by the Service.

     

    5 content provider

    Applications can save their data to files, SQL databases, or even any valid device. A content provider class implements a set of standard methods, so that other applications can save or read various data types processed by this content provider.

     

     

     

    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.