Advantages and disadvantages of IPC communication methods:
Comparison of IPC communication methods
Name |
Advantages |
Disadvantages |
Applicable scenarios |
Bundle |
Simple to use |
Only data types supported by bundles can be transferred |
Process communication for four components |
File sharing |
Simple to use |
It is not suitable for high concurrency scenarios and does not make instant communication between processes. |
Without concurrent access, exchanging simple data is a scenario where real-time is not high. |
Aidl |
Powerful, support one-to-many concurrent communication, support real-time communication. |
Using a bit more complex, you need to handle thread synchronization. |
One-to-many communications with RPC requirements |
Messenger |
Functions in general, support one-to-many serial communication, support real-time communication. |
Cannot handle high concurrency scenarios, RPC is not supported, data is transmitted through Messenger, so only the data types supported by the bundle can be transferred. |
Low concurrency of one-to-many instant communications, no RPC requirements, or no RPC requirements to return results. |
ContentProvider |
Access to data sources is powerful and supports one-to-many concurrent data sharing, and other operations can be extended through the call method. |
You can understand constrained aidl, which primarily provides CRUD operations for data sources. |
One-to-many inter-process data sharing. |
Socet |
Powerful, can transmit byte stream through the network, support a pair of high concurrent real-time communication. |
Implementation details are a little cumbersome and do not support direct RPC. |
Network data exchange. |
Note: RPC refers to a remote procedure call, that is, two servers A, B, an application is deployed on a server and wants to invoke the function/method provided on the B server.
Because it is not in a memory space, it cannot be called directly, it needs to express the semantics of the call through the network and convey the data of the call.
Android IPC Communication mechanism of the third, process communication mode.