Search code examples
androidaidl

Send data from Android AIDL to multiple clients


I have an Android device with serial port. I need to be able to run multiple applications simultaneously, and all of them should be able to send and receive data from the serial port. Since the serial port can only have one connection, I thought I should use one application that would communicate directly with the serial port. This application would have AIDL interface in order to allow other applications to send and receive data from it. I can successfully send data to the AIDL from other applications. My question is, how can I send data from the AIDL service to other applications.

I saw some examples that uses a callback for it, (e.g http://devarea.com/android-services-and-aidl/#.WydoR6czaUk).

In my case I need the AIDL service to be able to send the data to all connected clients app, without their request.

I know I can use custom Broadcast for that, but there's a lot of data coming from the serial port every second, and it might cause performance problem.


Solution

  • You can use Broadcasts to inform other apps (or use startService() to inform a Service of the other Apps). You can collect the data into packages and transmit them.