知道可能导致问题的原因是什么?
我执行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的:
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.
有什么想法吗?
答案 0 :(得分:0)
我没有正确的UUID,我通过获取正确的UUID然后在代码中替换它来解决它。
如何获取UUID:
ParcelUuid[] list = mmDevice.getUuids();