Send text through Bluetooth from Java Server to Android Client Send text through Bluetooth from Java Server to Android Client android android

Send text through Bluetooth from Java Server to Android Client


It looks like your BufferedWriter cache was not being flushed, the data was simply remaining in the buffer without being sent. Calling bWriter.flush() after your bWriter.write() should fix the issue and cause the data to be flushed to the output stream. You can also consider changing your code to follow this:

PrintWriter pWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outStream)));

This will cause the PrintWriter output to be buffered, instead of being written immediately to the output stream, which can be inefficient.

For your purposes though, omitting the BufferedWriter should be fine, as you will most likely want an immediate flush to the output stream (which PrintWriter does).