I am working on a Bluetooth application. It consists, among other things, of a list view displaying the paired and visible devices. Long clicking on the unpaired ones opens up the pairing dialog which I have implemented using this code-
Class class1 = Class.forName("android.bluetooth.BluetoothDevice");
Method createBondMethod = class1.getMethod("createBond");
int position = ((AdapterContextMenuInfo)item.getMenuInfo()).position;
boolean result = ((Boolean)createBondMethod.invoke(pairedDevices.get(position).getDevice())).booleanValue();
I have observed that this method returns immediately without waiting for the pairing to complete. But I need to know whether the pairing succeeded or not. Is this indicated in the function's return value or is there some other way of knowing it ?
Thanks in advance,
From the documentation:
Start the bonding (pairing) process with the remote device.
This is an asynchronous call, it will return immediately. Register for ACTION_BOND_STATE_CHANGED intents to be notified when the bonding process completes, and its result.