3 回答

TA贡献1854条经验 获得超8个赞
简单地说就是这样;
private class ConnectingThread extends Thread {
public ConnectingThread(BluetoothDevice device) {
BluetoothSocket temp = null;
BluetoothDevice bluetoothDevice = device;
// Get a BluetoothSocket to connect with the given BluetoothDevice
try {
temp = bluetoothDevice.createRfcommSocketToServiceRecord(uuid);
} catch (IOException e) {
e.printStackTrace();
}
bluetoothSocket = temp;
}

TA贡献1893条经验 获得超10个赞
定义最终变量需要内联实例化或在同一个类的构造函数中实例化。我的意思是以下几行:
private final BluetoothSocket bluetoothSocket;
private final BluetoothDevice bluetoothDevice;
这些变量必须在 的构造函数中初始化BT_Classic。
添加回答
举报