user723556
user723556

Reputation:

Bluetooth sending to a MAC address

I want to send some file via bluetooth to another device which is not discoverable. I have its MAC address.

I couldn't find any code/tutorial/help regarding this.

I pieced out a few things together from the documentation.

There is a bluetoothAdapter class which has a function,

getRemoteDevice(String address)

this will return a BluetoothDevice object to me. Then I can use

BluetoothDevice.createRfcommSocketToServiceRecord() to create a socket and call

connect() to attempt a connection to the remote device.

This however is not establishing a connection between the devices. (If I am doing it correctly.)

Can someone highlight or provide a code snippet of how to actually accomplish this connection and then send some file over?

Any help is much appreciated!

Upvotes: 2

Views: 2347

Answers (1)

Dennis Mathews
Dennis Mathews

Reputation: 6975

Your procedure is correct - it should connect.

What error message are you seeing when connection fails ? Are you ensuring that the other device is waiting for the connection ? i.e by doing the equivalent of listenUsingInsecureRfcommWithServiceRecord ?

Upvotes: 1

Related Questions