Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle the necessity of interprocess communication in my Android application? [closed]

My application requires me to periodically do the following:

  1. Send periodic heartbeat information to a server, once per 15 seconds
  2. Take periodic screen captures and send them to a server, once per 60 seconds
  3. Send message to and poll the server for messages, once every 5 seconds

I've written the services for each of the items listed above but here is where I need help, communication between those services...

The heartbeat service needs to be able to:

  1. Get some information from the screen capture service.
  2. Queue a message with the messaging service.

The screen capture service needs to be able to do the following:

  1. Fetch the current activity from my application
  2. Queue a message with the messaging service.

The messaging service needs to be able to do the following:

  1. Receive messages to queue up to be sent to the server from my application/services
  2. Send messages received from the server to the application

With all of the communication pathways required, I'm wondering how to do that? Would I just bind my application to all of the services? Bind services to other services? Use some other from of communication?

I need all of those services to continue running/functioning even if my application isn't in the foreground.

like image 575
Ryan Avatar asked Nov 22 '13 11:11

Ryan


People also ask

How is IPC Inter process communication performed in Android?

First of all IPC means Inter Process communication where two applications or processes will communicate with each other by passing some data between them. Since android is meant for embedded and small devices, we should not use serialization for IPC , rather we can use BINDERs which internally uses parcels .

Which framework provided interprocess communication between the application in the Android?

The Android Interface Definition Language (AIDL) is similar to other IDLs you might have worked with. It allows you to define the programming interface that both the client and service agree upon in order to communicate with each other using interprocess communication (IPC).


1 Answers

Provided more info in chat, but the general thrust is:

  • use AlarmManager to schedule invokations of a broadcast receiver
  • let the receiver re-schedule itself when invoked
  • let the receiver send a command to the service (this will start the service, if it's not running already)
  • let the service spin a thread
  • do HTTP in the thread
like image 141
Seva Alekseyev Avatar answered Sep 22 '22 21:09

Seva Alekseyev