我尝试使用bluetoothSocket连接我的电脑和手机上的Android应用
private void ConnectThread_BT(BluetoothDevice device) {
BluetoothSocket tmp = null;
mmDevice = device;
showToast("connectthread");
try {
tmp = device.createRfcommSocketToServiceRecord(uuid);
} catch (IOException e) { }
mmSocket = tmp;
showToast(mmSocket.toString());
}
public void run_BT() {
//btAdapter.cancelDiscovery();
showToast("runbt");
try {
mmSocket.connect();
showToast("connect");
} catch (IOException connectException) {
try {
mmSocket.close();
showToast(connectException.getMessage());
} catch (IOException closeException) { }
return;
}
我得到异常"失败的套接字可能关闭或超时,读取ret:-1" ...有没有人修复过这个问题?
感谢。祝你有美好的一天