I have a Bluetooth dual-mode device (Bluetooth classic + BLE). From my Android phone, I connect to the BLE interface through BluetoothDevice.connectGatt()
method, and to the Bluetooth Classic interface like
socket = bluetoothdevice.createRfcommSocketToServiceRecord(MY_UUID);
socket.connect();
If I connect to Bluetooth Classic first and then BLE, things work normally. But if I connect to BLE first and then Bluetooth Classic, I cannot connect to the Bluetooth socket, resulting in error:
java.io.IOException: read failed, socket might closed, read ret: -1
I tried the solution in this post but it didn't help in my case.