I'm afraid I'm not quite sure about your problem. Can't you create a socket for an already connected Bluetooth device?
First of all, if the device is already paired, you do not need to start the pairing process again. You just need to create a socket for communication, which will fail if the device is not available for communication. I have been doing some things lately, and I used the following code, which works great for me:
try { Method m = device.getClass().getMethod("createRfcommSocket", new Class[] { int.class }); BluetoothSocket mySocket = (BluetoothSocket) m.invoke(device, Integer.valueOf(1)); } catch (<VARIOUS EXCEPTIONS>) {
To request the user to select which device, you can request a BluetoothAdapter for all currently connected devices as follows:
Set<BluetoothDevice> bondedDevices = BluetoothAdapter .getDefaultAdapter().getBondedDevices();
Finally, you can create connections with multiple devices at the same time - see here: Android Bluetooth API connects to multiple devices
stephendnicholas
source share