I am trying to connect insecurely using bluetooth to a RFreader. I tried using the bluetooth chat example provided in the sample projects. I am using android 2.3 and above for this.
I have encountered many links for using
createInsecureRfcommSocketToServiceRecord()
along with
listenUsingInsecureRfcommWithServiceRecord(String, UUID)
- I have changed Bluetooth chat example according to my need.
- Initially it shows up the list of scanned devices(RF reader shows up).
After selecting a device, the
connectThread
will be invoked. It will create theBluetoothSocket
usingcreateInsecureRfcommSocketToServiceRecord()
.Then I am starting the thread which cancels discovery and calls
bluetoothSocket.connect()
.
But, it is failing here giving an **IOException:Service discovery failed**
. I have removed the code for AcceptThread()
which listens for connections, since I am explicitly connecting by selecting a device from list of scanned devices.
Am I doing any mistake ? Is there any other procedure for connecting to non-UI bluetooth devices ?
Thanks in advance :)