Client/server communication between a Java server and an Android phone
I'm looking for the best way to implement data transfer to and from an Android application.
Here's the solution I'm currently considering:
- Data are transferred using JSON, beans are serialized/deserialized using GSON
- Each object that can be transferred provides a "toBean" method and a constructor that takes a bean (enforced with a "Tr开发者_StackOverflowansferable" interface)
- Before serialization I add additional info to the bean such as the response status, time etc.
Does this look like a reasonable solution? is there another pattern I could/should be using?
What you are doing sounds reasonable, I would personally use SOAP/REST web service since it is Java to Java, but that is just a personal choice, the best choice would probably be determined by the details of your interactions with the server as well.
精彩评论