I have a Bluetooth application based on BluetoothChat. In fact, I've seen the same issue running that application as a test.
The app communicates with another Bluetooth device (not Android). That device doesn't always send all the data in one chunk to Android (although supposedly it does to other Bluetooth phones...like Blackberry). Sometimes the data comes over as one byte, followed by 9, followed by the final 9. I never see this when talking Android phone to Android phone, just Android phone to this device. Looking at the BluetoothChat application, there is no checking to see if the stream is complete. It just has a run that stays alive putting data into a buffer then sends that buffer to a Handler. Here is the exact code: public void run() { Log.i(TAG, "BEGIN mConnectedThread"); byte[] buffer = new byte[1024]; int bytes; // Keep listening to the InputStream while connected while (true) { try { // Read from the InputStream bytes = mmInStream.read(buffer); // Send the obtained bytes to the UI Activity mHandler.obtainMessage(BluetoothChat.MESSAGE_READ, bytes, -1, buffer).sendToTarget(); } catch (IOException e) { Log.e(TAG, "disconnected", e); connectionLost(); break; } } } Since the buffer never gets cleared, I would think that longer messages that come before shorter ones would show partly in the buffer. Also, there is no check to see if all of the data has been transmitted (doesn't read return a -1 when the end of the stream is hit and shouldn't that be checked?). Just curious if others have run into similar issues on Android and how they got around it. BTW, there is a BIG difference in Bluetooth connection ability between Android phones. I have one phone almost never connects while other phones do almost always. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en