I would like to write an Android application (let’s call it ‘ZX’) which communicate with other apps which are unknown in advance.
ZX doesn’t want to communicate with all the other apps. It only wants to communicate with apps approved by the user via a ZX-permission. ZX-permissions can be granted and revoked at any time by the user via one of the ZX’s activities.
In order to do that, ZX needs to know for sure which app is trying to communicate with it, and in the case of apps connecting for the first time with ZX it needs to display its name (or something else which uniquely identify it) to the user to ask if it should allow it or not.
Questions:
1) How to identify the calling app?
2) What IPC mechanism is recommended for that?
It’s sort of hard to give a great answer to this question because you’re being pretty cryptic with the details… However, I’ll take a stab at it..
Depending on what “ZX” does, something like the Observer Pattern could work for this. If applications wanted to communicate with ZX they would send ZX a message, adding themselves to a lookup table / list which ZX maintains.
Basically you’d have something like this…
Application
AIwishes to communicate with ZX. It sendsZXa message containing information about the application (whatever it is you need, IP Address etc.). This information could go to a function such asaddApplication()which makes a newCommAppobject storing all relevant information about the application.ZXcould then sendAIa unique authentication key which it could use for further communication. This could handle the actual session. Any further communication between the two applications can be authenticated with the unique key. This approach assumes you’re using authentication for identification of different apps rather than trying to keep “the bad guys” out.If you could expand on your actual situation I’d be happy to edit my question to suit your needs more.