Reputation: 193
So my problem is that i have created two applications, one for an android 2.2 phone and one for an android 2.3 phone.
Both applications has a class called Address which contains two strings.
The task is now that i have to pass an address object from one application to the other. My best bet is that i should use a thread on each applications that then connects to each other.
What im not sure about though, is if i should send the object as an object or if i should send the two strings one at a time from the address on the sender and assign them to a new address object on the reciever. Whats the easiest solution and do you guys have any tip on where i might find some guidance on a similar problem or do you have some smart solution to my problem?
Best Regards Drakthal
Upvotes: 1
Views: 336
Reputation: 13541
Why not pass the data in an intent to the other application instead of serializing the object? Just pack the Strings into the extras of the Intent's Bundle. Then handle it in the other application.
Upvotes: 1
Reputation: 28162
You could make the object into a String and send it as well. Gson can make this task very easy, so I'd give that a go.
It's quite easy to use. Deserialize an object:
Gson gson = new Gson();
MyClass object = gson.fromJson(json, MyClass.class);
Serialize an object:
Gson gson = new Gson();
String objectString= gson.toJson(myObject);
Upvotes: 0