[英]I never get out from BluetoothSocket.connect()
Any idea what might be causing the issue? 任何想法可能是导致问题的原因吗? I execute the connect()
function and no further code is executed. 我执行connect()
函数,不再执行任何代码。
CODE: 码:
void openBT() throws IOException
{
UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); //Standard SerialPortService ID
mmSocket = mmDevice.createRfcommSocketToServiceRecord(uuid);
mmSocket.connect();
mmOutputStream = mmSocket.getOutputStream();
mmInputStream = mmSocket.getInputStream();
beginListenForData();
myLabel.setText("Bluetooth Opened");
}
Logcat: Logcat:
05-01 20:10:00.569 24445-24445/bluetooth.example.com.bluetoothserial D/OpenGLRenderer﹕ Enabling debug mode 0
05-01 20:10:07.606 24445-24445/bluetooth.example.com.bluetoothserial D/BluetoothUtils﹕ isSocketAllowedBySecurityPolicy start : device null
05-01 20:10:07.606 24445-24445/bluetooth.example.com.bluetoothserial W/BluetoothAdapter﹕ getBluetoothService() called with no BluetoothManagerCallback
05-01 20:10:07.626 24445-24445/bluetooth.example.com.bluetoothserial D/BluetoothSocket﹕ connect(), SocketState: INIT, mPfd: {ParcelFileDescriptor: FileDescriptor[61]}
05-01 20:10:08.086 24445-24445/bluetooth.example.com.bluetoothserial I/Choreographer﹕ Skipped 31 frames! The application may be doing too much work on its main thread.
Any idea? 任何想法?
I wasn't having the right UUID, I solved it by obtaining the right UUID and then replacing it in the code. 我没有正确的UUID,我通过获取正确的UUID并将其替换为代码来解决它。
How to obtain UUID: 如何获取UUID:
ParcelUuid[] list = mmDevice.getUuids();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.