Does Parcelable use the correct way to send data between applications?

I am trying to understand how to communicate between applications on Android - not just between instances Activity.

I installed a “client” that sends the Messenger obj to the Service (in the Intentsent service); the service creates an Messageobj object and sends it back to the "client" using messenger.send(message). This works fine until I try to use Message.obj to store the object.

I created my own Parcelableclass MyParcelablein the service and put it in a post. Everything works until the message is sent to the "client". Unmarshall fails because the "client" does not have access to the class MyParcelable. This is obvious - they are in different packages (say com.whatever.myclientand com.whatever.myserver). Is this not so?

I also tried creating Parceland submitting it (both applications will have access to the class), but Parcelnot Parcelable. I read about the class loaders used, but I don’t understand how separate class loaders are in separate applications (processes, if I understand the Android architecture in this regard). That is, how can one classloader be “taught” about a class that exists in another classloader? Of course, there seems to be an obvious “this is how you do it,” but I haven't seen it yet.

+5
source share
3 answers

, ( ). MyParcelable MyParcelable Service, MyParcelable Service , ClassLoader, unmarshalling, unmarshalling , , MyParcelable, .

EDIT:

(a) MyParcelable 2 pkgs

( Service). Android ( Eclipse Android), JAR . , . ;)

(2) ClassLoader ( , )

ClassLoader . , ClassLoader , ;) , Activity#onCreate() Thread.currentThread.getContextClassLoader(). MyParcelable Service, , ClassLoader .

IPC AIDL, Parcelable.

+2

- ( cloud apis), , shared-holder. , obj () .

+1

, " ", . Bundle Message.obj. Bundle Parcelable, . , , , Bundle " " Android Java. Bundle, -, "sub-Bundles" . , , . - !

+1
source

All Articles