4
我想用android手機連接我的電腦以傳輸一些數據。對於計算機編程語言,我選擇了c#。用藍牙連接PC和Android手機(c#)
在計算機的代碼如下所示:
var wantedAddress="303926627f06";
var addr = BluetoothAddress.Parse(wantedAddress);
var cli = new BluetoothClient();
cli.Connect(addr, new Guid("{00001101-0000-1000-8000-00805f9b34fb}"));
而且在Android手機的代碼如下所示:
private UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
private BluetoothAdapter btAdapter= BluetoothAdapter.getDefaultAdapter();
private BluetoothServerSocket server=btAdapter.listenUsingRfcommWithServiceRecord("App name",uuid);
while(isRunning)
{
try {
BluetoothSocket socket=server.accept();
} catch (IOException e) {
isRunning=false;
e.printStackTrace();
}
}
試圖連接到手機後,我得到這個錯誤:
SocketException:
The requested address is not valid in its context 303926627F06:0000110100001000800000805f9b34fb
有誰知道什麼是錯的?
謝謝你的幫忙! Jure
您是否解決了此錯誤?我也處於相同的情況 – Mirodil 2015-02-14 14:57:55