开发者

Client/server communication between a Java server and an Android phone

开发者 https://www.devze.com 2023-03-22 19:13 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消