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