0
votes

On a Samsung nexus S OS (4.0.1) when I pair with another Bluetooth device it's pairing and connecting. Once Bluetooth is paired and then try to reconnect again then it is throwing IOException exception and phone will crash.

My Bluetooth code:

try{
mBluetoothAdapter.cancelDiscovery();        
mmSocket = device.createInsecureRfcommSocketToServiceRecord(uuid);
mmSocket.connect();
}
catch(IOException e){
e.printStackTrace(); 
}

java.io.IOException: Service discovery failed
android.bluetooth.BluetoothSocket$SdpHelper.doSdp(BluetoothSocket.java:431)
android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:224)
1
Can you post the stack trace?GHC
See this link stackoverflow.com/questions/3031796/… maybe help youmr.boyfox

1 Answers

1
votes

I had this problem; my solution was to sleep the thread for 1000ms between the last communication on the socket and the call to socket.close().