Chapter 5. Interprocess Communication
Android application threads most often communicate within a process, sharing the process’s memory, as discussed in Chapter 4. However, communication across process boundaries—i.e., interprocess communication (IPC)—is supported by the Android platform through the binder framework, which manages the data transactions when there is no shared memory area between the threads.
The most common IPC use cases are handled by high-level components in Android, such as intents, system services, and content providers. They can be used by an application without it having to know whether it communicates within the process or between processes. Sometimes, however, it is necessary for an application to define a more explicit communication model and be more involved in the actual communication. This chapter covers how threads communicate across process boundaries, which includes:
- Synchronous and asynchronous remote procedure calls (RPCs)
-
Message communication through
Messenger
-
Returning data with
ResultReceiver
Android RPC
IPC is managed by the Linux OS, which supports several IPC techniques: signals, pipes, message queues, semaphores, and shared memory. In Android’s modified Linux kernel, the Linux IPC techniques have been replaced[8] by the binder framework, which enables an RPC mechanism between processes; a client process can call remote methods in a server process as if the methods were executed locally. Hence, data can be passed to the server process, executed ...
Get Efficient Android Threading now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.