0

My app connects to a BT device and sends and receives some data and then pauses until the user chooses how to continue. Then the established connections is being used and the app continues.

But on some Nexus 4.3 devices the system drops the established Bluetooth connection in the pause when the user is asked how to preceed. During this pause there is no communication on the BT connection

This doesn't happen on all Android 4.3 devices, only on some. I tried several brand new ones and there is no problem. But some users who already use their Nexus for a while report that problem.

I even tried closing the connection to be reestablished with exactly te same code I use at the beginning. But I get different kinds of errors.

This is how I close the connection:

public void resetConnection() {
if (mmInStream != null) {
    try {
    mmInStream.close();
    } catch (Exception e) {
           ...log it
    }
    mmInStream = null;
}

if (mmOutStream != null) {
    try {
    mmOutStream.close();
    } catch (Exception e) {
           ...log it        }
    mmOutStream = null;
}

if (mmSocket != null) {
    try {
    mmSocket.close();
    } catch (Exception e) {
           ...log it        }
    mmSocket = null;
}

}

Basically to connect I use this code Disconnect a bluetooth socket in Android

All the Android versions and kernels are the same on the working and non working devices. But "used" devices (even after restart - not reset) have that problem - but so far all could solve the problem after a factory reset.

Any idea what could be the problem on these Nexus 4.3 and how to solve it?

Certainly not every user just wants to do a factory reset on his phone - and I am not even sure this always resolves the problems.

And unfortunately I do not have such a Nexus in my hands that causes the problem - otherwise I could debug it and try. So I am totally in the dark to what is going on in 4.3 with BT here.

Community
  • 1
  • 1
user387184
  • 10,953
  • 12
  • 77
  • 147

1 Answers1

1

I have a nexus 3 and I confirm the problem. My work around was to communicate regularly on the bluetooth. If you are in pause for more than 2 or 3s, the bluetooth always disconnects. In my app, I managed not to wait a user input for several seconds, then the app reads a sensor every 100ms and it never disconnects.

JJM
  • 178
  • 1
  • 2
  • 9