Is it possible for us to connect multiple devices ? who can share the code for me! This problem has troubled me for a long time! Thanks!
I would say that code isn't the problem. The correct implementation is managing a thread for each connection however I have found that the number of devices you can connect to simultaneously is limited based on the phone's implementation of Bluetooth. Bluetooth spec states 7 devices can be connected however I have found android phones that can only handle 1 bluetooth connection while others can handle 6. It would really help the Bluetooth development community if someone from the Android development team could go more in depth here.
Yes, you can set up multiple bluetooth connections (at least RFCOMM connections). Just use a alternative thread for you connection, and it would work fine (I guess) See also: http://developer.android.com/resources/samples/BluetoothChat/index.html
Edit, commented layout is unreadable: In the connectThread function, change:
tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
to:
Method m = device.getClass().getMethod("createRfcommSocket", new Class[] {int.class});
tmp = (BluetoothSocket) m.invoke(device, 1);
Yes to connect multiple devices in bluetooth server socket in can try this lib
Like Barry said, you can connect to multiple devices. Just make a new thread for each connection. You'll want to have a list of the 'ConnectThread's and 'ConnectedThread's that you're keeping track of. So you only have to adapt it for multiple threads (and implementing the ability to select multiple devices, of course). I've done this, and it's not too hard.
If you want to connect to a device and then connect to another (one-by-one using the original menus), then you might have some more work to do.
For making a multiple connection you have to make separate thread for each and every devices which you want to connect. Each threads have separates methods for read and write data to remote device.
see this link
© 2022 - 2024 — McMap. All rights reserved.