在Android蓝牙中设置连接以连接到另一台设备。它显示可用的设备,但是当我开始连接时它没有连接。这是我的代码:
我尝试过多次更改UUID,以便无论是否发生相同的错误,它都相同
// Make a connection to the BluetoothSocket
try {
// This is a blocking call and will only return on a
// successful connection or an exception
mmSocket.connect();
Log.d(TAG, "run: ConnectThread connected.");
} catch (IOException e) {
// Close the socket
try {
mmSocket.close();
Log.d(TAG, "run: Closed Socket.");
} catch (IOException e1) {
Log.e(TAG, "mConnectThread: run: Unable to close connection in socket " + e1.getMessage());
}
Log.d(TAG, "run: ConnectThread: Could not connect to UUID: " + MY_UUID_INSECURE );
}
connected(mmSocket,mmDevice);
但这是日志。它没有连接到android设备。
02-14 15:24:24.060 8364-8364/com.example.zachmarcelo.mypurse D/BluetoothConnectionServ: start
02-14 15:24:24.064 8364-8364/com.example.zachmarcelo.mypurse D/BluetoothConnectionServ: AcceptThread: Setting up Server using: 0000110a-0000-1000-8000-00805f9b34fb
02-14 15:24:24.066 8364-9322/com.example.zachmarcelo.mypurse D/BluetoothConnectionServ: run: AcceptThread Running.
02-14 15:24:24.066 8364-9322/com.example.zachmarcelo.mypurse D/BluetoothConnectionServ: run: RFCOM server socket start.....
02-14 15:24:26.360 8364-8364/com.example.zachmarcelo.mypurse D/BluetoothConnectionServ: startClient: Started.
02-14 15:24:26.449 8364-8364/com.example.zachmarcelo.mypurse D/BluetoothConnectionServ: ConnectThread: started.
02-14 15:24:26.450 8364-9324/com.example.zachmarcelo.mypurse D/BluetoothConnectionServ: ConnectThread: Trying to create InsecureRfcommSocket using UUID: 0000110a-0000-1000-8000-00805f9b34fb
02-14 15:24:26.463 8364-9324/com.example.zachmarcelo.mypurse D/BluetoothSocket: BT connect calling pid/uid = 8364/10188
02-14 15:24:28.543 8364-9324/com.example.zachmarcelo.mypurse D/BluetoothSocket: close() this: android.bluetooth.BluetoothSocket@ecc0ea9, mSocketState: INIT
02-14 15:24:28.544 8364-9324/com.example.zachmarcelo.mypurse D/BluetoothConnectionServ: run: Closed Socket.
02-14 15:24:28.544 8364-9324/com.example.zachmarcelo.mypurse D/BluetoothConnectionServ: run: ConnectThread: Could not connect to UUID: 0000110a-0000-1000-8000-00805f9b34fb
02-14 15:24:28.544 8364-9324/com.example.zachmarcelo.mypurse D/BluetoothConnectionServ: connected: Starting.
02-14 15:24:28.544 8364-9324/com.example.zachmarcelo.mypurse D/BluetoothConnectionServ: ConnectedThread: Starting.
需要连接到设备。但是,它没有连接,也没有传递数据