What are the IPC mechanisms available in the Android OS?

前端 未结 5 465
终归单人心
终归单人心 2020-11-30 18:20

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
5条回答
  •  攒了一身酷
    2020-11-30 19: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 :)

提交回复
热议问题