Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to initialize BluetoothDevice object with known mac address in android?

I want to initialize BluetoothDevice object with known mac address but, I do not know how to initialize.

Please guide me how to initialize the below object with the mac address 00:11:22:33:44, I would be very thankful for your kind response.

BluetoothDevice device;
like image 961
Android Avatar asked Jan 30 '26 06:01

Android


1 Answers

Lets assume that String address = "00:11:22:33:44";

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

BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
like image 200
Mr. Jones Avatar answered Jan 31 '26 21:01

Mr. Jones