0

I have an android phone and a barcode scanner. To use the scanner I pair it with the phone but in my application I want to a some point to disconnect the scanner, so to do this I thought that an unpair would be enough. I tried the accepted answer from here but it doesn't work. Maybe the BluetoothDevice object it's not correct?

String mac = BluetoothAdapter.getDefaultAdapter().getAddress();
BluetoothDevice bluetoothDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(mac);

Actually I didn't understand what address to put in getRemoteDevice() method so I put the phone bluetooth mac address. Should I put there other address? I would appreciate any answer.

Thank you in advance

Community
  • 1
  • 1
Laura
  • 2,653
  • 7
  • 37
  • 59

1 Answers1

0

once you select your scanner , you will be storing it in

BluetoothDevice device;

then just fetch the address by using device.getAddress();

and if you are calling your unpair in different activity , then just pass the address as bundle and then fetch the remote device by using:

BluetoothDevice bluetoothDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address);

I hope this will work.

nam_ph
  • 233
  • 1
  • 3
  • 12