3

As stated in the title, the my bluetooth socket will only make a connection if it is ran in the debugger. When i put a breakpoint on the connect(), it connects when i step over taking about a second to connect. When I try running in release it immediately throws an IOexception stating that read from the socket failed. I am running on android 5.1.1

Code that attempts connection

BtCommThread(BluetoothDevice btDevice, BluetoothInterface btInterface) throws IOException {//let caller handle Exception with constructor
    callbacks = btInterface;
    device = btDevice;
    socket = device.createRfcommSocketToServiceRecord(BluetoothService.uuid);
    socket.connect();//attempt connection
    input = new BufferedReader(new InputStreamReader(socket.getInputStream()));//get input
    output = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));//get output
}

What could cause the bluetooth socket to work in only the debugger? I have implemented a service that retries constructing my BtCommThread and connecting the socket if it fails up to ten times. I have also tried adding a simple thread sleep before the connect thinking it could possibly be a timing issue. I am really at a loss.

Does anyone have an idea what might help?

Hardware Information

Android Phone: Google Nexus 5

Linux System: Udoo MCU running debian armhf

Community
  • 1
  • 1
alan7678
  • 2,223
  • 17
  • 29
  • Have you solved this? I'm having a similar problem on Android, Samsung S6. At first I assumed it was a missing permission in Android.xml, but alas, no. – Sam Ballantyne May 11 '16 at 18:36
  • I was never able to figure it out. It should be noted that I was originally running on kitkat/4.4 without problems. – alan7678 May 12 '16 at 02:49

0 Answers0