I try to read a file via Bluetooth with HTC Desire.
The code for connection is similar to BluetoothChat sample http://developer.android.com/tools/samples/index.html. The problem is in the ConnectedThread when reading files with size greater than 5 KB. This is the run() method of this thread (I removed the code that is unnecessary for the understanding of the problem): public void run() { // Keep listening to the InputStream while connected int bufferSize = 2048; byte[] buffer = new byte[bufferSize]; int num = 0; int offset = 0; while (true) { try { // Read from the InputStream offset = mmInStream.read(buffer, num, 1024); num = num + offset; Log.d("Read", "offset = " + offset); if(num > bufferSize - 1024) { num = 0; offset = 0; } } catch (IOException e) { connectionLost(mAddress); break; } } } The local variable *offset* is never greater than 127. And when I try to read a 7K file mmInStream.read method blocks after a few seconds and doesn't return. I attempted to use different buffer sizes and read(buffer,0, bufferSize) method instead of the one given above. But it doesn't help. It seems like the inputstream internal buffer is overflowed before the reading completed. Does anyone have an idea how to prevent it? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

