4
votes

Im doing bluetooth based application, I want to connect other devices like nokia devices, and printer.

I refer the android bluetooth documentation http://developer.android.com/guide/topics/connectivity/bluetooth.html. It demonstrates all the fundamental Bluetooth API capabilites, And I did these all the things

Scanning for other Bluetooth devices
Querying the local Bluetooth adapter for paired Bluetooth devices
Establishing RFCOMM channels/sockets
Connecting to a remote device
Transfering data over Bluetooth

i get reference from BluetoothChat, samples of android.

BluetoothChat This application send data to another android device but for that this application must be installed in both the devices.

Like this How to send file from Android device to other device through Bluetooth by code

What i want is

  1. I want to send file from one device to another device from my application and that also works even another device not running our application. i.e. Receiver device also able to receive file using default Bluetooth.

Is this possible in android?

2

2 Answers

0
votes

I think this is not possible.

in fact, when you create a bluetooth socket, you have to use createRfcommSocketToServiceRecord(UUID)

This function requires an UUID that is a string shared between the applications on the two devices so the connection can be established.

Without a bluetooth socket listening on the other device, with the exact same UUID, you won't be able to share data.

0
votes

You can do connection between two BT devices easily. You just need to call

createRfcommSocketToServiceRecord(UUID)

with UUID that understand receiver device. For file transfer action UUID must be equal (for example) to 00001106-0000-1000-8000-00805F9B34FB (File transfer service)

So you connection code might looks like code below

BluetoothDevice device = mBluetoothAdapter.getRemoteDevice("00:0A:94:16:77:A0"); BluetoothSocket clientSocket;

try {
    log(TAG, "Remote device " + device);
    ParcelUuid[] uuids = device.getUuids();
    boolean isFileTransferSupported = false;
    UUID ftpUID = UUID.fromString("00001106-0000-1000-8000-00805F9B34FB");
    // Check if remote device supports file transfer
    for (ParcelUuid parcelUuid: uuids) {
        if (parcelUuid.getUuid().equals(ftpUID)) {
            isFileTransferSupported = true;
            break;
        }
    }
    if (!isFileTransferSupported) {
        log(TAG, "Remote bluetooth device does not supports file transfer ");
        return;
    }
    clientSocket = device.createRfcommSocketToServiceRecord(ftpUID);
    clientSocket.connect();
} catch (IOException e) {
    return;
}