What are the IPC mechanisms available in the Andro

2019-01-16 03:22发布

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

To my knowledge are:

1) Intents,
2) Binders.

5条回答
Rolldiameter
2楼-- · 2019-01-16 03:36

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.
查看更多
虎瘦雄心在
3楼-- · 2019-01-16 03:36

All the answers are good and concise in this post. But i would like to light upon which IPC mechanism should i 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 :)

查看更多
Anthone
4楼-- · 2019-01-16 03:37

IPC is inter-process communication. It describes the mechanism how different types of android components are communicated.

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 the data is passed through. It is similar to the serialization of an object, but much faster on android. Bundle can be got from intent via the getExtras() method.

3) Binders are the entity which allows activities and services obtain a reference to another services. It allows not simply send messages to services but directly invoke methods on them.

查看更多
劫难
5楼-- · 2019-01-16 03:37

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

  • Intents (with Bundles included)
  • Binders or Messengers with a Service
  • BroadcastReceivers
查看更多
霸刀☆藐视天下
6楼-- · 2019-01-16 03:43

There are three types of the IPC mechanisms:

  1. handler
  2. implementing binder
  3. AIDL
查看更多
登录 后发表回答