Reputation: 3457
I created the list that have device detected, and I want to send data to each device; The process is : one device sent data to first device and after disconnect first device and start to connect second device and sent the same data to second device and after disconnect this process until the last device in device list.
So does it possible to do that?
Upvotes: 4
Views: 3032
Reputation: 34301
I have never done so but reading on different threads on Internet, I found that
You can send data using Bluetooth to multiple device.
For that you will have to connect with each device using different UUID
.
You can go throught this post to get more understanding.
Upvotes: 2
Reputation: 29672
I am telling you logic part only, because frankly I haven't done this in Android platform.
You can not send file to two device at a same time, because Bluetooth Connection is synchronized, so only one connection at a time is allowed.
You can use following code for sending file,
BluetoothDevice device; String filePath = Environment.getExternalStorageDirectory().toString() + "/data.txt";
ContentValues values = new ContentValues();
values.put(BluetoothShare.URI, Uri.fromFile(new File(filePath)).toString());
values.put(BluetoothShare.DESTINATION, device.getAddress());
values.put(BluetoothShare.DIRECTION, BluetoothShare.DIRECTION_OUTBOUND);
Long ts = System.currentTimeMillis(); values.put(BluetoothShare.TIMESTAMP, ts);
Uri contentUri = getContentResolver().insert(BluetoothShare.CONTENT_URI, values);
Upvotes: 4