1

Well there are plenty of question already have been asked on StackOverflow about how to paired & connect a remote bluetooth device with android. I have tried all the of them, haven't find any proper link or documentation regarding pairing with remote device.

Also about I have tried connecting my laptop with android programmatically, but I was getting following error:

java.io.IOException: Service discovery failed
at android.bluetooth.BluetoothSocket$SdpHelper.doSdp(BluetoothSocket.java:395)
at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:209)

There are number of reference for connecting android device, one that I follow is this. But it's not working in my case. I am trying to connect with my vaio laptop and I have Samsung Galaxy S android device.

If anybody knows how to pair as well as connect the device programmatically then please tell me the solution.

Community
  • 1
  • 1
Pawan
  • 1,503
  • 2
  • 19
  • 28

1 Answers1

1

Your client will never discover the server if the server is not actually discoverable. Your server code's comment says "Make sure the device it discoverable," but listening on a socket does not mean the device is discoverable. You can make the server discoverable by calling:

Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
startActivity(discoverableIntent);

This is all covered in detail in the Android dev guide: http://developer.android.com/guide/topics/wireless/bluetooth.html

your application must has the following bluetooth permissions in manifeast file:

android.permission.BLUETOOTH_ADMIN
android.permission.BLUETOOTH
Shankar Agarwal
  • 34,573
  • 7
  • 66
  • 64
  • 1
    I am not making android chat client application, where both peer are Android. Here I am trying to connect with Laptop and Car's bluetooth, I think using A2dp, I have to connect with these devices. If anybody is having experience then please share.. – Pawan Apr 15 '12 at 15:31