O'Reilly logo

Efficient Android Threading by Anders Goransson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. Interprocess Communication

Android applications 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, that 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, content providers, etc. 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 (RPC).
  • 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 a Remote Procedure Call (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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required