I am trying to increase the transfer speed on android bluetooth. I 
experimented transferring a 2.7MB buffer from one android device to another 
using RFComm socket of the Bluetooth API (see code below). It took ~70 secs 
to complete. I compared this method against the "Share" via bluetooth 
function that came with the phone. The "Share" function gave exceptionally 
better performance (~15 secs to transfer a 2.7MB file). 

How does the "Share" function differ from using the Bluetooth API? How can 
I replicate the "Share" method to get optimized transfer speed?

Thanks,

Bluetooth API test code:

Server side - installed on one android device


Thanks,

Bluetooth API test code:


Server side - installed on one android device


BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mServerSocket = 
mBluetoothAdapter.listenUsingRfcommWithServiceRecord("DeviceName", MY_UUID);
socket = mServerSocket.accept();
mInStream = socket.getInputStream();int totalByte = 1;while (totalByte < 
2718720) {
    int bytesAvailable = mInStream.available();
    if (bytesAvailable > 0) {
        totalByte += bytesAvailable;
        byte[] buffer = new byte[bytesAvailable];
        mInStream.read(buffer);
    }}

Client side - installed on other android device


mClientSocket = device.createInsecureRfcommSocketToServiceRecord(
                MY_UUID);
mClientSocket.connect();
mOutStream = mClientSocket.getOutputStream();byte byteValue = 0;for (int i=0; 
i<2718720; i++) {
    byteValue++;
    mOutStream.write(byteValue);}

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/89894d05-269a-4a6f-b9d0-124e77a590f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to