Commit 0acbf126 authored by Andreas Schildbach's avatar Andreas Schildbach
Browse files

ScannerFragment: Remove bluetooth pairing.

parent 4c088aeb
......@@ -88,6 +88,17 @@ class ScannerFragment : Fragment() {
fun deviceClicked(device: Device) {
System.out.println("===== deviceClicked " + device)
bluetoothAdapter.bluetoothLeScanner.stopScan(callback)
bluetoothAdapter.getRemoteDevice(device.btMac).createBond();
val bluetoothDevice = bluetoothAdapter.getRemoteDevice(device.btMac)
if (bluetoothDevice.bondState == BluetoothDevice.BOND_NONE) {
System.out.println("= creating bond " + device)
bluetoothDevice.createBond()
} else if (bluetoothDevice.bondState == BluetoothDevice.BOND_BONDED) {
System.out.println("= removing bond " + device)
removeBond(bluetoothDevice)
}
}
fun removeBond(device: BluetoothDevice) {
device.javaClass.getMethod("removeBond").invoke(device)
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment