76

Will any one please tell me what are all the IPC mechanisms that are present in Android.

To my knowledge are:

  1. Intents
  2. Binders

7 Answers 7

103

IPC is inter-process communication. It describes the mechanisms used by different types of android components to communicate with one another.

1) Intents are messages which components can send and receive. It is a universal mechanism of passing data between processes. With help of the intents one can start services or activities, invoke broadcast receivers and so on.

2) Bundles are entities of data that is passed through. It is similar to the serialization of an object, but much faster on android. Bundle can be read from intent via the getExtras() method.

3) Binders are the entities which allow activities and services to obtain a reference to another service. It allows not simply sending messages to services but directly invoking methods on them.

5
  • and this universal mechanism is implemented by the means of ...what? (expecting something among the lines of kernel system calls, extensions to java found in dalvik, etc.)
    – n611x007
    Apr 24, 2015 at 15:18
  • 8
    Bundle could be seen as coming with Intent, and don't forget BroadcastReceiver. Here are the words from Android Official Page: "We strongly encourage you to instead use Android system functionality for IPC such as Intent, Binder or Messenger with a Service, and BroadcastReceiver". developer.android.com/training/articles/security-tips.html#IPC
    – Sam003
    Jul 10, 2015 at 1:13
  • 1
    Can someone please add examples? Newcomers would understand it faster if there are use cases for each IPC type.
    – guettli
    Sep 14, 2015 at 9:45
  • different types of android components or different types of Android process? Sep 10, 2016 at 4:22
  • Doesn't the "binder" actually bases all mentioned mechanisms in Android? We know Android Binder Framework provides the kernel capability for IPC.
    – ctk2021
    Feb 4, 2021 at 20:48
44

There are three types of IPC mechanism in Android:

  1. Intents (along with Bundles)
  2. Binders
  3. ASHMEM (Anonymous Shared Memory) - The main difference between Linux shared memory and this shared memory is, in Linux other processes can't free the shared memory but here if other processes require memory this memory can be freed by Android OS.
5
  • 1
    Doesnt AIDL come in this ??
    – Raa
    Jun 18, 2013 at 9:03
  • 6
    Binders include AIDL. It's only an language, which helps you generating the Binder Interface for the IPC. Jul 22, 2013 at 10:16
  • Only uses ASHMEM if you know what you're doing. The compatibility between different android versions is not guaranteed. Dec 5, 2013 at 18:55
  • 4
    Should be added UNIX sockets and pipes
    – aberaud
    Apr 13, 2015 at 17:50
  • 1
    What about Content Providers and Broadcasts?
    – Mit_
    Apr 16, 2019 at 7:05
24

All the answers are good and concise in this post. But I would like to light upon which IPC mechanism should we use. First of all IPC means Inter Process communication where two applications or processes will communicate with each other by passing some data between them. Since android is meant for embedded and small devices, we should not use serialization for IPC, rather we can use BINDERs which internally uses parcels. Parcel is a sort of light weight serialization by using shared memory concept.

There are many differences between Binder IPC and Serialization IPC:

1. Serialization is very heavy to use in embedded devices, communication will be very slow.

2. Binders uses Parcels to make IPC very fast.

3. Binders internally uses Shared memory concept which uses less memory while sharing data between two processes.

Bottom Line: Binders uses less memory, and quite fast as it uses parcels. Serialization is very heavy, takes time to send and receive data, and also it takes more memory compared to binders.

Note: To pass data between activities, services, and receivers use only Bundles. Don't go for either serialization or binders. Binders are specifically used only for binder services where 2 processes will communicate.

Hope this Helps :)

22

As written on Android Developers page, IPC mechanisms in Android include:

  • Intents (with Bundles included)
  • Binders or Messengers with a Service
  • BroadcastReceivers
1
  • 1
    All of them are based on binder IPC. May 7, 2019 at 0:35
6

There are three types of the IPC mechanisms:

  1. handler
  2. implementing binder
  3. AIDL
1
  • 1
    handler is not. Messenger is.
    – John
    Feb 22, 2019 at 6:22
2

The tree specific inter-process communications in Android are:

  1. AIDL which is a two way with concurrent operation.
  2. Messanger aa a two way but not concurrent
  3. Broadcast as a one way Also, you can use sockets but it's not recommended.
0

Another solution that worked for me was using the Internal files:

https://developer.android.com/training/data-storage#filesInternal

Write from one process, close file, read from another.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.