[英]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. 在Samsung nexus S OS(4.0.1)上,当我与另一个蓝牙设备配对时,它正在配对和连接。 Once Bluetooth is paired and then try to reconnect again then it is throwing IOException exception and phone will crash.
蓝牙配对后,尝试再次重新连接,则抛出IOException异常,手机将崩溃。
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)
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().
我的解决方案是在套接字上的最后一次通信与对socket.close()的调用之间使线程休眠1000ms。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.