In the bluetoothChat application example, the data sent and received is added to an ArrayAdapter named mConversationArrayAdapter . There, each character is added to the array.
In my case, I have a row instead of an array, because I do not need to send and receive several data, I only need to send one row and each time I get one row.
The problem I get is that if I first get a string like hello world and then get a shorter one, the first one is overwritten by the second one and not the first one is deleted and the new one is written.
So, if I get hello world , and then I guess I need to get bye , then I really get byelo world .
So how can I flush the buffer every time I get what I want?
Code snipers
Send data:
byte[] send1 = message_full1.getBytes(); GlobalVar.mTransmission.write(send1);
Record a call:
public void write(byte[] out) { ConnectedThread r; synchronized (this) { if (GlobalVar.mState != GlobalVar.STATE_CONNECTED) return; r = GlobalVar.mConnectedThread; } r.write(out); }
Create topic:
public void write(byte[] buffer) { try { GlobalVar.mmOutStream.write(buffer); GlobalVar.mHandler.obtainMessage(GlobalVar.MESSAGE_WRITE, -1, -1, buffer).sendToTarget(); } catch (IOException e) {} }
Finally, read the "Subject":
public void run() { byte[] buffer = new byte[12];
source share