Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Messenger (lightweight alternative to AIDL) be used for cross-application communication?

Tags:

android

ipc

aidl

A quick question: the Android docs say very clearly that Messenger is an alternative for AIDL for IPC (inter process communication). They never explicitly say though if this extends to processes running in different applications, or just within one app. I strongly suspect the former, but wanted to check.

Thanks! Jan

like image 851
Jan Żankowski Avatar asked Mar 30 '11 10:03

Jan Żankowski


People also ask

What is the difference between using Messenger and AIDL?

This technique allows you to perform interprocess communication (IPC) without the need to use AIDL. Using a Messenger for your interface is simpler than using AIDL because Messenger queues all calls to the service. A pure AIDL interface sends simultaneous requests to the service, which must then handle multi-threading.

When would you use AIDL?

# When to use AIDLYour service wants to handle multithreading for IPC(any method defined in service can be executed simultaneously by more than one application). If you want to share data and control something in another application. You want to create some new functionalities and distribute them as a library.

What's AIDL?

The Android Interface Definition Language (AIDL) is similar to other IDLs you might have worked with. It allows you to define the programming interface that both the client and service agree upon in order to communicate with each other using interprocess communication (IPC).

What are the IPC Mechanisms in Android?

There are 3 basic methods used for IPC on Android: AIDL. Messenger. Broadcast.


1 Answers

AIDL is only really used for inter-app IPC. While it is possible to use AIDL for internal communication, it doesn't buy you anything and puts limitations on your Binder implementations.

Moreover, one application does not have more than one process, in the vast majority of cases. There is little reason for most apps to have multiple processes.

Messenger, createPendingResult(), ResultReceiver, private broadcast Intents -- all of these are ways for a service to communicate with a client across process boundaries.

like image 200
CommonsWare Avatar answered Sep 22 '22 05:09

CommonsWare