I try to open a socket for listening for incomming connection from a non-android device.
Parcelable[] uuidExtra = device.getUuids();
String t = uuidExtra[0].toString();
t = t.toUpperCase();
Log.i("UUID: ", t);
This codesnippet will give me the UUID of the service provided by my bluetooth device. The output from LogCat is:
00001105-0000-1000-8000-00805F9B34FB
Which I believe is the UUID of Obex Object push profile. I assume this because the manufacture of the device told me that the device only supports on protocol: Obex Push Profile.
When I try to access for instance the second element in my Parcelable[] array, the output will only be
07-12 13:29:36.305: E/AndroidRuntime(6293): java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
By that I can say for sure that my array only contains one object.
So over to more android specific bluetooth stuff.
I’am using this UUID this way:
try {
tmp = adapter.listenUsingRfcommWithServiceRecord(device.getName(), UUID.fromString(t));
} catch (IOException e) {
Log.e(TAG, "FAILED BECAUSE: " + e.getMessage()); }
The exception outputs the following to LogCat:
FAILED BECAUSE: Not able to register SDP record for: "name of the device"
After a couple of hours googling this exception I still can’t figure out how I can open a listening socket for my device.
Any suggestions? Thanks in advance!
So if anybody is curious about this, or facing the same issue as I did, here is the solution:
The error:
Not able to register SDP record for: "name of the device"will be thrown because you are trying to create a service with a aUUIDthat is already taken. In this case, I tried to register my own service, with the sameUUIDas theObex Object PushWhat I had to do, is to register my own service, with a custom UUID, for instance
This UUID is generated from this webpage. As for now you have created a new listening socket:
And we are now ready to accept incomming requests, this way:
Remeber, this is a blocking call, so for yourself and your users, please put this in a
thread.So why the heck doesn’t my device connect to the android server?
Are you sure that the remote device/client is using the same UUID as the server?
if you cant specify the UUID for the remote device, please contact the manufacture maybe the are nice enough to send you a config file, which is my case.
If there is any questions, please add a comment to this post. I will accept this as an answer since nobody had a solution to this.