Search code examples
androidprocessshared

Getting Data Between Android Processes


In an app I am designing, I have a back end service connected to a communication bus collecting a bunch of data and communicating with remote devices. I have a front end (UI) in another APK and process.

I need to have quite a bit of data, communication events and user events flowing at very high speeds (microseconds) between these two processes. Here's an example: Process A might receive a block of data that makes up a bitmap image via the communications bus. Since this process is not in the main UI thread I cannot use the Canvas and Bitmap classes to create an actual bitmap, all I can do is just store the data. Process B (the UI thread) needs this data to actually create and display a bitmap image. Passing the data from Process B to Process A needs to happen very fast - hopefully like the amount of time a call from one method to another occurs in the same process.

As a newbie to Android, I am struggling with this concept. I have looked at AIDL and it looks promising, but I don't know yet.

Does anyone have any ideas on how to share data back and forth between two processes at reasonably high speed?


Solution

  • You are right, the best thing to communicate between processes in Android is AIDL.

    The only possible way I can imagine to improve performance even more - is to share memory between processes. However I think you'll need to go low-level for this. You can check for example this article: http://www.androidenea.com/2010/03/share-memory-using-ashmem-and-binder-in.html

    However, in most cases, AIDL should be pretty fast.

    Good luck