I. Basics
1. Android is a multi-user system
2. By default, Android assigns an independent user name to each application. Only the Android system knows the user name, but the application system itself does not. Android assigns the user the permissions required for the application.
3. Each application runs in an independent Vm, so different applications cannot be accessed.
4. By default, each application runs in an independent Linux Process. When any component in the application is executed, Android starts the process.
Interaction between applications:
1. Two applications can be specified to share the same user name, so that the two programs can access each other's files.
2. All applications can apply for access permissions such as contacts, short messages, and memory cards during installation.
Application components:
1. Activity: An activity corresponds to a display page. The activity in an application can be called by other applications.
2. Service: A service is a component running in the background. It does not have a UI and can be started by other components.
3. contentprovider: provides a data interaction method.
4. broadcastreceiver: used to respond to a system-level notification without a UI, but can generate a status bar notification.
Interaction between various components:
1. You can start the activity by passing intent to startactivity or startactivityforresult.
2. You can start the service by passing the intent to startservice, or by passing the intent to bindservice to bind to a service.
3. You can initialize a broadcast by passing intent to sendbroadcast, sendorderedbroadcast, or sendstickybroadcast.
4. You can access contentresolver by calling the query method.
Androidmenifest. xml
Before starting an application component, android must use the androidmenifest. xml file to load the component. The androidmenifest. xml file must be placed in the root directory of the application.
* Define all components in the Application
1. Declare the permissions required for the Application User Name
2. define the minimum level of the required API
3. Define required hardware and software
4. APIs other than Android required by the application
# Declare Components
<? XML version = "1.0" encoding = "UTF-8"?> <Br/> <manifest...> <br/> <application Android: icon = "@ drawable/app_icon.png"...> <br/> <activity Android: Name = "com. example. project. exampleactivity "<br/> Android: Label =" @ string/example_label "...> <br/> </activity> <br/>... <br/> </Application> <br/> </manifest>
<Activity>, <service>, and <provider> must be declared in menifest. Otherwise, these components cannot be accessed.
<Cycler> it can be declared in menifest or dynamically defined by registerreceiver in code.
By declaring <intent-filter> in a component, you can specify the intent that the component responds.
Activity Status:
1. Resume-foreground activity and has the user focus status, or running
2. paused-other activities are on the front end and have the user focus, but the application is not completely overwritten. All attributes of the application will be saved in the memory, however, when the memory is very short, the system will terminate the application.
3. Stopped-the activity running in the background is maintained in the memory, but the system may release its memory.
Activity callback function:
1. oncreate-executed when activity is created
2. onstart-execute when activity is about to be visible
3. onresume-after the activity has become visible
4. onpause-the other activity changes to the current status
5. When onstop-activity is invisible, the status is stopped
6. ondestory-activity will be destroyed soon
When rewriting the preceding method, you must first call the corresponding method of super.
Full Lifecycle of an activity: oncreate-> ondestory
Activity visible lifecycle: onstart-> onstop
Activity foreground lifecycle: onresumt-> onpause
Lifecycle when activity a starts Activity B:
1. The onpause of A is called.
2. The oncreate, onstart, and onresume sequence of B is called.
3. If a is not displayed, onstop of A is called.