2

I would like to know how I can connect to multiple Bluetooth server applications (written in Java) from Android mobile phone. Every server application has different UUID.

I referenced some code from Android's Bluetooth Chat application, but tmp = device.createRfcommSocketToServiceRecord(MY_UUID); which seems to enable me to set what UUID to connect to, does not work on the application as it causes Service Discovery Failed Exception.

A workaround was found on another Stackoverflow question Service discovery failed exception using Bluetooth on Android where the solution is to replace the code above with

Method m = device.getClass().getMethod("createRfcommSocket", new Class[] {int.class});
tmp = (BluetoothSocket) m.invoke(device, 1);

The Bluetooth application now works with the desktop app like a charm, but it seems that with the new way of invoking Bluetooth socket via reflection, there is no way to set UUID that I want to connect to.

Is there any solution to the problem?

Community
  • 1
  • 1
segfault
  • 5,759
  • 9
  • 45
  • 66
  • You need to know what UUID those Bluetooth server application are using, and then pass same UUID from your client (Android app). SPP UUID is supported on almost all Bluetooth devices. – Mudassir Apr 13 '12 at 03:32
  • @segfault you got any solution to this problem ? – Hunt Dec 30 '12 at 07:19

0 Answers0