Trev16v, First of all, thanks for your initial feedback.
To serialize my object, I used the serializeObject and deserializeObject classes from http://www.jondev.net/articles/Android_Serialization_Example_(Java ) They seem to work well: if I serialize an object (created from a class that implements Serializable) from the phone / activity and deserializes it from the same phone, I manage to get the object from the generated byte [].
Then I tried to use the same code in the BluetoothChatServices class in the bluetooth chat example in another to send the serialized object to another phone (in this example there is
public ConnectedThread(BluetoothSocket socket) { Log.d(TAG, "create ConnectedThread"); mmSocket = socket; InputStream tmpIn = null; OutputStream tmpOut = null; // Get the BluetoothSocket input and output streams try { tmpIn = socket.getInputStream(); tmpOut = socket.getOutputStream(); } catch (IOException e) { Log.e(TAG, "temp sockets not created", e); } mmInStream = tmpIn; mmOutStream = tmpOut; }
and bytes are transmitted using
public void write(byte[] buffer) { try { mmOutStream.write(buffer);
and read with
public void run() { Log.i(TAG, "BEGIN mConnectedThread"); byte[] buffer = new byte[10240]; int bytes;
The problem with using BluetoothChatServices is that the byte array received on the other phone is different from the one sent when it comes to serialized objects. For example, to give the idea element [0] of a serialized object = -84 when I send it, the one I receive from another phone has the element [0] - [4] = 0, then [5] = 4 and all the others items are also not aligned. I tried to write and run above in the methods to change Inputstream and Outputstream from ObjectInputStream and ObjectOutputstream, but to no avail (if this was to be implemented, I can publish the code that I tried to use)
Again, thank you very much for your help, I am new to all of these concepts, so if I say stupid things, I will also be happy to turn to the textbook
thanks