Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 799
eold Avatar asked Feb 16 '11 11:02

eold


People also ask

When would you use AIDL?

# When to use AIDLYour service wants to handle multithreading for IPC(any method defined in service can be executed simultaneously by more than one application). If you want to share data and control something in another application. You want to create some new functionalities and distribute them as a library.

What is startActivity?

Starting activities or services. To start an activity, use the method startActivity(intent) . This method is defined on the Context object which Activity extends. The following code demonstrates how you can start another activity via an intent.

What is Android intent Action view?

An intent allows you to start an activity in another app by describing a simple action you'd like to perform (such as "view a map" or "take a picture") in an Intent object.


1 Answers

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.

like image 96
ns476 Avatar answered Oct 01 '22 15:10

ns476