Android: Outputstream.write - problem

I am trying to transfer a file to a remote bluetooth device as follows

    while (availableBytes > 0 ) {

                 bytesRead = inStream.read(tempData,0,tempData.length);

                 mmOutStream.write(tempData,0,bytesRead);  
                 mmOutStream.flush();
                 availableBytes = inStream.available();
    }/* End of availableBytes */

While writing to a large file (500 KB), I get an IO exception as "IOException: connection timeout" after 12-15 minutes. When I send a small file that contains <100 KB, I successfully transfer. I do not close the socket while the file transfer is in progress. Are there any restrictions in Android that the Bluetooth connector can only be active for a fixed period?

Please cast your eyes on this

+3
source share
1 answer

InputStream.available () does not do what you think:

, ( ) .

, bytesRead == -1, EOF (End-of-File).

+1

All Articles