It is required to teach the Android device to send and receive commands as an array of bytes over a TCP connection. Transmitted commands are known in advance, received data is not. In this case, when sending a command, the first few bytes will be informational. Tell me how to properly perform this task? Is it worth using Serialization / Parcebale for this purpose or you can do with standard inputstream / outputstream . If the second option, which command is better to use for I / O. It seems to me that ByteArrayInputStream is most suitable here, but almost all examples use BufferedOutputStream , DataOutputStream or FileOutputStream .

  • Serialization / Parcebale allows you to transfer objects. If you want to transfer simple data, you can do without them. - Vladyslav Matviienko
  • @metalurgus I need to send commands like this: "0xFFF1", how do I understand this 16-bit encoding? When you try to get this in a variable gives an error. How to transfer such commands? - MrStuff88
  • int a = 0xfff1 - Vladyslav Matviienko
  • If you need to dynamically save values ​​from a string, you can: Integer.decode(hexString) . For example, int a = Integer.decode("0x4d2"); - Vladyslav Matviienko
  • @metalurgus thanks, and if you declare it like this - byte a = (byte) 0xFFF1; Will it be another value? - MrStuff88

0