It is already asked but i didn\'t find any solution. For bluetooth application i am using the bluetoothShare.class
.
My source code for sending the file to
Maybe you can try another solution with BufferedWriter and BufferedReader.
Here is a snipped code:
BluetoothDevice mmDevice;
Set mBluetoothAdapter;
BluetoothAdapter bAdapter = BluetoothAdapter
.getDefaultAdapter();
mBluetoothAdapter = bAdapter.getBondedDevices();
for (BluetoothDevice bc : mBluetoothAdapter) {
if (bc.getName().indexOf("name_of_bluetoothdevide") != -1) {
UUID uuid = UUID
.fromString("00001101-0000-1000-8000-00805F9B34FB"); // Standard
// SerialPortService
// ID
mmDevice = bc;
BluetoothSocket mmSocket = mmDevice
.createInsecureRfcommSocketToServiceRecord(uuid);
bAdapter.cancelDiscovery();
mmSocket.connect();
BufferedWriter Writer = new BufferedWriter(
new OutputStreamWriter(
mmSocket.getOutputStream()));
Writer.write("Bluetooth connected!");
Writer.flush();
app.setmSocket(mmSocket);
break;
}
}
And for reading:
BufferedReader Reader = new BufferedReader(
new InputStreamReader(mmSocket.getInputStream()));
receivedMsg = Reader.readLine();
Hope it can help you.