Situation:
I have an Android System Application (persistent) with a Service
that is supposed to run all the time. (Let's call it Service A)
Then there is another Application (not a System Application; normal App) that also has a Service
. But this Service
might run or might not run since the Android OS will kill it if it needs resources. (Let's call it Service B)
In short: We have two Applications (hence 2 APKs) that can be signed with the same certificate. (So they could run in the same process right?)
What I try to accomplish
The Service A listens to events. When it receives an event then I want the Service A to call the normal App (Service B) which should give a response back to Service A.
Approaches to let the two Services communicate
I could let them communicate using:
- Binding (using an AIDL)
- Messaging (but not optimal since passing complex objects is a must)
Problems
- Which way to communicate is "the best" one for the described case?
- What happens when Service A wants to delegate/send a message to Service B and Service B is not running? It must get a response from Service B. Should I always start Service B if it is not running when Service A wants to call it?
Thank you!