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
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.
Messenger internally uses AIDL,it can be used in multiple applications.As per android documentation a Messenger service can be used for communication between two processes but it does not restrict it in same application.Processes can be in same application or different application.
Messenger should be used if we want the requests to be processed sequentially as it enters the messages in handler's queue and they are processed one by one whereas in AIDL all requests will be handled at once and it becomes developer's responsibility to maintain thread safety.