Android bluetooth socket.connect() fails
android, bluetooth, connection, sockets
Solution
I had the same problem. It's easy to resolve. You have to configure your RFID reader to SPP protocol with his configure program and after this he will work.
Problem
I'm trying to make a connection between an android device and a RFID reader bluetooth. To do this i use the code of bluetooth chat (bluetooth chat example). But when i do `mmSocket.connect();` at line 329 of the bluetooth chat example, the connection generate every time a `java.io.IOException`. I tried also this method to get the socket: ``` tmp = mDevice.createRfcommSocketToServiceRecord(MY_UUID); Method m = mDevice.getClass().getMethod("createRfcommSocket", new Class[] {int.class}); tmp = (BluetoothSocket) m.invoke(mDevice, 1); ``` but nothing. I tried with 3 difference devices. The first, a Samung S2 running android 4.4.2 give me this error: ``` failed:read failed, socket might closed, read ret: -1 ``` With a tablet running android 4.0.3 give me this error: ``` IOException: Connection refused ``` The curiosity is that if i try to connect my phone with my tablet i fail. But if i run in 2 devices this application, and with one i try to connect the second, while the second is searching some devices to connect, the connection is succesfull. But only if the second device is running this application and searching some devices to connect. I tried also to unpair but nothing. Finally i wanted to say that if i try to connect the 2 devices or one device with my rfid bluetooth reader throught settings the connection is succesfull. And last i wanted to say that when i'm trying to connect the 2 devices or the device with the reader rfid, if the devices isn't paired, compare a dialog that ask me to pair the 2 device but after this the connection failed.