我在android中通過藍牙發送圖像,並且想要獲取圖像發送到的設備的MAC地址。如何獲得藍牙連接設備的MAC地址在android中
請在下面找到我的代碼。
private void bluetoothadd(){
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
// Device does not support Bluetooth
Log.e("Bluetooth ","not found");
}
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivity(enableBtIntent);
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
// If there are paired devices
if (pairedDevices.size() > 0) {
// Loop through paired devices
for (BluetoothDevice device : pairedDevices) {
Log.e("Mac Addressess","are: "+mBluetoothAdapter.getRemoteDevice(device.getAddress()));
}
}
}
}
我得到所有配對設備的MAC地址。我只想要一個設備的MAC地址是傳輸數據的。
您要查找的地址,當其它設備連接到用戶的設備,或建立(恢復階段)的連接,甚至之前.. ??? – Shiva
我想要一個其他設備連接時的地址,我可以得到數據發送到哪個設備的MAC地址。 –
檢查以下鏈接 http://stackoverflow.com/questions/10795424/how-to-get-the-bluetooth-devices-as-a-list http://stackoverflow.com/questions/16471204/discovering-bluetooth-devices-listview-will-not-get-updated –