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

And*_*oid 2 android bluetooth-lowenergy

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

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

BluetoothDevice device;
Run Code Online (Sandbox Code Playgroud)

Mr.*_*nes 10

让我们假设 String address = "00:11:22:33:44";

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

BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
Run Code Online (Sandbox Code Playgroud)