Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dalvik to Java SE communications

I'm planning on developing an app for android that requires a back-end server to sync data with other users of the app. I'm planning on writing this server in standard java running on a unix server.

I once did this directly between two android devices, in that case I just serialized all the data needed to be sent on both ends.

However I suspect that the format that Dalvik serializes to and Java SE's format are not compatible. Is this the case? And if it is, what are my alternatives? One thing that popped into my mind was sending raw xml over a socket, but if there are better alternatives I'll be glad to hear them.

Thanks.

like image 954
monoceres Avatar asked Dec 13 '22 16:12

monoceres


1 Answers

If you are doing a server then you should rely on something more standard like XML or JSON. I personally favor JSON. You shouldn't expect all your client to be Java friendly. Almost every mobile device support JSON. Look at Jackson library to generate your json. Then you can use Jackson again to deserialize your object.

The beauty of this solution is also stupid simple. You can look at the content by just just putting the request in your browser. Not so easy with binary data.

like image 76
Amir Raminfar Avatar answered Dec 15 '22 04:12

Amir Raminfar