我的应用程序连接到 BT 设备并发送和接收一些数据,然后暂停,直到用户选择如何继续。然后正在使用已建立的连接并且应用程序继续。
但在某些 Nexus 4.3 设备上,当询问用户如何继续时,系统会在暂停中断开已建立的蓝牙连接。在此暂停期间,BT 连接上没有通信
这不会在所有 Android 4.3 设备上发生,仅在某些设备上发生。我尝试了几个全新的,没有问题。但是一些已经使用 Nexus 一段时间的用户报告了这个问题。
我什至尝试使用与我一开始使用的完全相同的代码关闭要重新建立的连接。但我得到不同类型的错误。
这就是我关闭连接的方式:
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.