Android - IPC, aidl and IBinder
Android provides a IPC (Inter-Process Communication) mechanism that is the preferred mechanism for communicating between process. The surprising thing to me is that this interface is synchronous.
What is so surprising is that communication across processes is inherently slow and not reliable and they recognize that when Activities communicate they suggest using messaging (Intents) . But when you create a Service and want to “bind” to that service so you can communicate bi-directionally, i.e. the Service is returning information to its client. You use aidl/IBinder which is a JMI type interface where the services are exposed as a series of method calls which are synchronous.
Of course since bound interfaces are synchronous they advise against using it to communicate directly between the Service and an Activity as can be seen here:
“IPC calls are synchronous. If you know that an IPC service takes more than a few milliseconds to complete, you should not call it in the Activity/View thread, because it might hang the application (Android might display an “Application is Not Responding” dialog).”
So it seems if there is a remote Service you wish to bind to you need to create a Local Service with an asynchronous interface to your Activity and a synchronous interface to the Remote Service.
Weird!
spawn a new thread and deal with it there
Comment by rektide — January 5, 2008 @ 7:52 pm