在我的移动应用程序中,我必须获取连接的BT地址并启动SPP连接。有没有办法获得连接的BT设备地址?
答案 0 :(得分:0)
以下可能会对您有所帮助
public void getDeviceList(){
BluetoothAdapter mBlurAdapter= BluetoothAdapter.getDefaultAdapter();
Set<BluetoothDevice> pairedDevices = mBlurAdapter.getBondedDevices();
if (pairedDevices.isEmpty()) {
Log.e("DeviceActivity ",
"Device not founds");
return ;
}
for (BluetoothDevice devices : pairedDevices) {
Log.d("DeviceActivity", "Device : address : " + devices.getAddress() + " name :"
+ devices.getName());
}
}
另外不要错过定义权限