Android Bluetooth Connection - Service Discovery Failed

15,335

Solution 1

I don't know and I still don't understand the UUID stuff but the problem was the UUID. I'm using the UUID which I got from the kernel logs and it is 00001105-0000-1000-8000-00805F9B34FB.

Solution 2

Its working for me

BluetoothSocket socket = device.createInsecureRfcommSocketToServiceRecord(MY_UUID);
Method m = device.getClass().getMethod("createInsecureRfcommSocket", new Class[] {int.class});
socket = (BluetoothSocket) m.invoke(device, 1);
bluetoothAdapter.cancelDiscovery();
socket.connect();

Solution 3

The following code snippet works for me. Try it...

BluetoothDevice mmDevice;
boolean temp = mmDevice.fetchUuidsWithSdp();
UUID uuid = null;
if( temp ){
uuid = mmDevice.getUuids()[0].getUuid();
}
tmp = device.createRfcommSocketToServiceRecord(uuid);

Solution 4

I worked through a similar learning process. I have tried to document what I learned in a series of examples.

This one might be of help:

http://digitalhacksblog.blogspot.com/2012/05/android-example-bluetooth-simple-spp.html

It is for setting up a simple connection between an Android device and a PC via bluetooth. The examples contain the Android files as well as an SPP server in java and one in perl for the PC.

Hope this helps.

Solution 5

Make sure that your app is not trying to connect while the adapter is busy with discovery: It appears the problem was that before I called

clientSocket.connect()

I needed to call

btAdapter.cancelDiscovery()

This helped solve the same problem for me Matts Reco

Share:
15,335
juliadream
Author by

juliadream

Updated on June 23, 2022

Comments