Sending data between IOs and Android? (ByteArray)

会有一股神秘感。 提交于 2019-12-25 06:38:08

问题


I am working on an networked application in Android that should be able to communicate with the IOs app. I am using Appwarps multiplayer back-end and there is a function to send and receive data. The function accepts a byte-array, so Initially I thought I could serialize a 'message' object into a byte-array and send that across - however would the IOs app be able to decode this back into the object?

Same applies to the other side, as the IOs app would have to serialize and send the object that Android would have to save back into the object. I guess I don't entirely understand how Byte-Arrays store entire objects and what the methods we use do to get them back to the object.

Any help/advice or linking to a useful article would be useful! (I tagged this question for both IOs and Android, as either side could potentially help)


回答1:


You'll need a common way to model the data so that both Objective C and Java can interpret that serialized object. Google-gson works great for JSON serialization of Java objects and Objective-c has tools for parsing JSON as well.

Protobuf is also fantastic for this sort of thing. For more info, check out this SO post asking a similar question.



来源:https://stackoverflow.com/questions/32670164/sending-data-between-ios-and-android-bytearray

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!