0

I am new to android development. I want to send data using Bluetooth but the following exception coming.

Connecting To Bluetooth Failed.
java.io.IOException: [JSR82] connect: Connection is not created (failed or aborted).
at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:397)
odacPkg.odac.BluetoothCommunication.run(CommunicationActivity.java:493)

Following is my source code.

        final UUID applicationUUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
        btDevice=bluetoothAdapterObj.getRemoteDevice(deviceMAC.toUpperCase());
        try {               
            BluetoothSocket btSocket = btDevice.createRfcommSocketToServiceRecord(applicationUUID);
            btSocket.connect();
            OutputStream outStream = btSocket.getOutputStream();
            outStream.write(sendData);
            btSocket.wait(CommunicationActivity.PACK_TIMEOUT);
            InputStream inStream = btSocket.getInputStream();
            inStream.read(receiveData);
            outStream.flush();
            outStream.close();
            outStream.close();
        }   
        catch (Exception e) {

        }
Nalaka526
  • 11,278
  • 21
  • 82
  • 116

1 Answers1

-2

It's not an issue coming from your code, I solved it simply rebooting android devices. I guess ther is something strange in the operative system of android devices , at least for version 4.1 jelly bean.