Arulselvam
Arulselvam

Reputation: 11

Android Bluetooth pairing and reconnect failed

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)

Upvotes: 0

Views: 848

Answers (1)

djilk
djilk

Reputation: 387

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().

Upvotes: 1

Related Questions