I am working on an App that connects the android device with another device (CAN modules) over Bluetooth.
I pair previously unpaired devices like this:
Method m = device.getClass().getMethod("createBond", (Class[]) null);
m.invoke(device, (Object[]) null);
Which works like a charm.
There is an issue though. The CAN Modules are set up in a way that you don't need the pin stuff or any other form of pairing confirmation, you just say that you want to pair with the device and it'll do so. Now, what happens if my App tries to connect to a Bluetooth device that is not a CAN Module, like a phone for example?
In that case, a Dialog appears asking the User to confirm the pairing. I don't mind the dialog, BUT I would like to react to the "Cancel" button in some way.
To sum it up:
I want to call method doSomething() when the User presses Cancel on the Bluetooth Pairing Confirmation Dialog. Is this possible?