2013-07-30 32 views
0

我非常新的三星(藍牙低功耗)SDK。問題是我想獲得幾個試圖連接到我的手機的設備的地址。請幫幫我。提前致謝。如何獲得設備的地址嘗試通過藍牙連接到移動設備

Pradeep。


謝謝Akuzma,

此功能給所有配對設備。但我需要獲取當前與手機通信的設備的地址。例如,如果我的手機連接到3個設備,但目前它只與第一個設備通信。所以我需要獲取該設備的地址,而不是獲取連接設備的所有地址。

謝謝。

回答

0

使用BluetoothAdapter

http://developer.android.com/guide/topics/connectivity/bluetooth.html

Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices(); 
// If there are paired devices 
if (pairedDevices.size() > 0) { 
    // Loop through paired devices 
    for (BluetoothDevice device : pairedDevices) { 
     // Add the name and address to an array adapter to show in a ListView 
     mArrayAdapter.add(device.getName() + "\n" + device.getAddress()); 
    } 
} 
+1

謝謝Akuzma, 此功能給所有配對設備。但我需要獲取當前與手機通信的設備的地址。例如,如果我的手機連接到3個設備,但目前它只與第一個設備通信。所以我需要獲取該設備的地址,而不是獲取連接設備的所有地址。 謝謝。 –

相關問題