如何用android中的已知mac地址初始化BluetoothDevice对象?

时间:2014-08-04 10:38:05

标签: android bluetooth-lowenergy

我想用已知的mac地址初始化BluetoothDevice对象但是,我不知道如何初始化。

请指导我如何用mac地址00:11:22:33:44初始化下面的对象,我非常感谢你的回复。

BluetoothDevice device;

1 个答案:

答案 0 :(得分:4)

让我们假设 字符串地址=" 00:11:22:33:44&#34 ;;

final BluetoothManager bluetoothManager =
        (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
mBluetoothAdapter = bluetoothManager.getAdapter();

BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);