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。
添加回答
舉報