Android Four Components summary

Source: Internet
Author: User

1:actiivty

User-visible and operable interface

Activity Open Mode: Startactivityforresult

: startactivity

Activity life cycle: OnCreate onStart onresume onPause onStop OnDestroy Onrestart

The life cycle of the screen switch: Destroy the activity first and create a new activity

Activation mode of activity:

1:stardand (Standard mode)

2:singletop (single top mode)

3:singletask (single task mode)

4:singleinstance (Single instance mode)

Intent (Intention) function: Turn on the component, pass the data

Open component: Activity broadcastreceiver Service

Passing data: Eight basic types and their arrays in Java

Serializable

Parcelable

Bundle

Intent

Category: Explicitly specify a bytecode file for a class directly

Scenario: Turn on components in your app

Advantages: Simple code writing, high efficiency

Implicitly opens the target component, goes back to match the intent filter, if the match succeeds then turns on and throws an exception if the match fails.

Scenario: Turn on your own components in other applications

Pros: Code writing complexity, low efficiency

2:broadcastreceiver (broadcast received): The system by broadcast mass message, as long as the registered recipients can receive

Features: As long as the receiver installed on the phone, whether or not launched, can receive a specific broadcast.

Version difference: If the user forces the broadcast recipient to stop, the lower version can receive a specific broadcast, the high version is not, if you want to receive, restart the app once

Common system broadcasts:

SD card Plug and Unplug

Application uninstallation and Installation

Dial-Out call

SMS arrives

Screen lock screen unlock

Battery charge Change

How to register:

Registering in the manifest file

Registering in code

Classification:

Shuffle broadcast:

As long as the recipient registers a broadcast specific action, it can accept the broadcast

Orderly broadcast:

The recipient receives the broadcast according to the first level from the high to the bottom

Pros: Priority 1000 ~ ~-1000 Priority default is 0

High-priority recipients can intercept the end-of-broadcast

The final broadcast recipient can be specified: No matter how the previous recipient intercepts the stop broadcast, it is the last to receive the broadcast and does not need to be registered in the manifest file

        

3:service (Service)

Aidl (interprocess communication)

4:contentprovider (content Provider)

Android Four components summary

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.