Android Remote methods (AIDL) vs Intents - performance & battery usage

3.5k Views Asked by At

My team is working on an Android project which consists of several Android applications which exchange data (on the same phone). The idea is to have several applications which are collecting some data and send this data to the main application. The main challenge here is to do the exchange as cheap as possible in terms of CPU load & battery usage.

As far as I know, there are two ways to achieve inter-process communications:

  1. Intents & activities - one activity catches the intents of another
  2. Remote methods (through AIDL)

I wonder which of these is more efficient in the following scenarios:

  1. Very frequent messages/method calls with very little data sent/traffic (e.g. just passing a bunch of primitives)
  2. Less frequent messages/method calls with large traffic chunks (e.g. collect data and periodically send a few KB/MB of data)
  3. Very frequent messages/method calls with large data chunks exchanged

I would appreciate any help, either in terms of comparison or a reference/link to a benchmark.

3

There are 3 best solutions below

3
On BEST ANSWER

I think for 1) you'd be best with a remote service and for 2) and 3) you'd be better off writing to files or a database. Intents are more for infrequent interprocess communication and starting apps and services.

0
On

You could also try to use native code to create a shared memory as an alternative option. Check out this link for details: http://www.androidenea.com/2010/03/share-memory-using-ashmem-and-binder-in.html

0
On

I suggest you use the Unix domain sockets mechanism to address scenario 3). The high frequency will make the use of files/databases complicated, and according to this answer, using Android's IPC is not recommended performance wise, since every object has to be converted to (and back from) a Parcel which takes time.. You can also use Unix pipes but it has some restrictions: