I am trying to understand how to communicate between applications in Android - not just between Activity
instances.
I set up a 'client' that sends a Messenger obj to a Service (in the Intent
sent to the service); the service creates a Message
obj and sends it back to the 'client' using messenger.send(message)
. This works fine until I try to use the Message.obj to hold an object.
I created my own Parcelable
class MyParcelable
in the service and put it into the message. All works until the message is unmarshalled in the 'client'. The unmarshall fails because the 'client' has no access to the MyParcelable
class. That's obvious - they are in different packages (say com.whatever.myclient
and com.whatever.myserver
). Is this completely the wrong way to go about this?
I have also tried creating a Parcel
and sending that (both applications would thereby have access to the class) - but Parcel
is not Parcelable
. I have read about class loaders being used but do not understand how separate class loaders in separate applications (processes, if I understand Android architecture in that regard). That is, how can one class loader be 'taught' about a class that exists in the other class loader? It certainly seems like there should be an obvious 'this is how you do it' but I have not seen it yet.