IPC (inter-process communication) means that inter-process communication refers to the process of data exchange between two processes.
How do I open multiple processes in Android?
You only need to assign the Android:process attribute to the four components (Activity, Service, Receiver, ContentProvider) in Android Menifest .
Different process components have independent virtual machines, application, and memory space, and intuitively understand the equivalent of two different UID applications.
In different processes, the presence of in-memory data is non-disruptive and has no effect on other processes.
Problems caused by multiple processes:
1, static member variables, singleton mode, and so on, the data in memory is completely invalid.
2, application will create multiple
3. Thread synchronization is completely invalid
Intent intention, intention
Although the intent component is not the four components, but it is the bridge connecting the four components, learning this knowledge, it is also very important.
Intent is a runtime binding mechanism that connects two different components in the course of a program's operation. With intent, your program can express some kind of request or intention to Android, and Android will choose the appropriate component to respond to the desired content.
Figure 1-1 Communication via intent
If Activity1 need to contact Activity2, they do not need to contact directly, but through intent as a bridge.
Intent consists of the following components:
- Component (component): Destination component
- Action: An act used to express intention
- Category (category): The categories used to represent actions
- Data (data): Represents the action to be manipulated
- Type (data type): Description of the data paradigm
- Extras (Extended information): Extended information
- Flags (flag bit): The mode of operation that expects this intent
The intent type is divided into explicit intent (direct type), implicit intent (indirect type). The official recommendation is to use an implicit intent. In the above attributes, the component property is a direct type and the others are indirect types.
Implicit intnet is a lot more subtle than the explicit intent, which does not explicitly indicate which activity we want to start, but instead specifies a series of more abstract actions and category information, which is then referred to the system to analyze the intent. and help us find the right activity to start.
Android Basics Learning