Skip to content
Advertisement

Buetooth connection failed: read failed, socket might closed or timeout, read ret: -1

I am trying to create a Bluetooth connection.

I can search for nearby devices but when I try to connect I get an error I do not understand:

LOGCAT

JavaScript

I Have two classes for connect, one that receives the device and execute the connection, an other for make connection.

ConexionActivity.Java

JavaScript

ConnectThread.java

JavaScript

Imports

JavaScript

Advertisement

Answer

Try to use ,

createInsecureRfcommSocketToServiceRecord(MY_UUID)

in place of

createRfcommSocketToServiceRecord(MY_UUID)

This should fix the problem. Share your debugging results , if this doesn’t fix the issue.

Also , don’t generate random UUID(s), try the one below.

UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement