2

I am developing an OBEX OPP client application in android phone.Through the client application i will send an object to the non Android device (which will act as the OPP server).I have created the RFCOMM socket connection using the API

createRfcommSocketToServiceRecord(OPP_UUID); I have use the UUID of the OBEX Push i.e.

private static final UUID OPP_UUID = UUID .fromString("00001105-0000-1000-8000-00805F9B34FB");

I have observed that through this the socket connection is successful and I got the input and output stream of the socket to send and recieve the data.But when I send the data the data recieved the other device is not in the right format. What I mean by this is in the reciever device the data is recieved with the error. BT Air sniffer indicates that the in the retrieved_opcode Data is not present.OBEX response code is Bad request.

Can anyone guide me what is wrong in this ? or the steps to make an OBEX OPP connection with the device which is not paired.

Your valuable inputs will help me to overcome this.

Thanks, Shekhar

Shekhar Joshi
  • 171
  • 1
  • 2
  • 5

1 Answers1

3

You should be able to pair the device, you can also do it from the bluetooth settings on the device, but you cannot connect with it and send the data directly like SPP comunication.

OBEX is a protocol, with his own headers, packets, etc..

There isn't an API to communicate through OBEX in Android that you can use programmatically. (You can be able to connect to the device, but then you can just read/write bytes).

You can send a file to a paired device through obex in a couple of ways:

With the ACTION_SEND intent, that will popup a menu with the application that can handle the file type you want to send, from which the user will need to select bluetooth, and then the device.

Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse(SDCardPath + "file.jpg"));
startActivity(Intent.createChooser(share, "Share Image"));

Or you can use another method if you don't want any dialog in your application, check the following question, it has an update with a working solution:

Sending a File using Bluetooth OBEX Object Push Profile (OPP)

Community
  • 1
  • 1
BFil
  • 12,966
  • 3
  • 44
  • 48