Ich benutze eine Bluetooth-Bibliothek, die ich online genannt Multi-Bluetooth, um eine Reihe von Clients zu verbinden. Ich teste mit 2 Android-Handys, 1 läuft 5.0 und die anderen 6.0. einen Server, auf dem 6.0-Telefon und einen Client auf dem 5,0 Telefon funktioniert laufen, aber wenn ich die Rollen umkehren ich diesen Fehler:Socket möglicherweise geschlossen Android-Fehler auf Android 6.0 nur
04-07 00:27:03.507 7499-8393/com.ramimartin.sample.multibluetooth W/BT: Fallback failed. Cancelling.
java.io.IOException: read failed, socket might closed or timeout, read ret: -1
at android.bluetooth.BluetoothSocket.readAll(BluetoothSocket.java:900)
at android.bluetooth.BluetoothSocket.waitSocketSignal(BluetoothSocket.java:859)
at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:535)
at com.ramimartin.multibluetooth.bluetooth.client.BluetoothConnector$FallbackBluetoothSocket.connect(BluetoothConnector.java:203)
at com.ramimartin.multibluetooth.bluetooth.client.BluetoothConnector.connect(BluetoothConnector.java:59)
at com.ramimartin.multibluetooth.bluetooth.client.BluetoothClient.run(BluetoothClient.java:54)
at java.lang.Thread.run(Thread.java:818)
Hier ist der Teil, wo ich die Störung erhalte:
public BluetoothSocketWrapper connect() throws IOException {
boolean success = false;
while (selectSocket()) {
adapter.cancelDiscovery();
try {
bluetoothSocket.connect();
success = true;
break;
} catch (IOException e) {
//try the fallback
try {
bluetoothSocket = new FallbackBluetoothSocket(bluetoothSocket.getUnderlyingSocket());
Thread.sleep(500);
bluetoothSocket.connect();
success = true;
break;
} catch (FallbackException e1) {
Log.w("BT", "Could not initialize FallbackBluetoothSocket classes.", e);
} catch (InterruptedException e1) {
Log.w("BT", e1.getMessage(), e1);
} catch (IOException e1) {
Log.w("BT", "Fallback failed. Cancelling.", e1);
}
}
}
if (!success) {
throw new IOException("===> Could not connect to device: " + device.getAddress());
}
return bluetoothSocket;
}
Vielen Dank im Voraus.
Der Bildschirm ist die ganze Zeit, also bedeutet das nicht, dass ich nicht in den Schlafmodus eingetreten bin? Danke BTW –
Nein, dann ist es nicht im Doze-Modus - Tiefschlaf. Wenn Sie über diese Bibliothek https://github.com/arissa34/Android-Multi-Bluetooth-Library sprechen, wird klar gesagt, dass "diese Bibliothek mit dem Android SDK 2.3 bis 5.1 kompatibel ist". So könnten sie Probleme auf Android 6.0 haben –
Ich versuche, es mit Android 6.0 kompatibel zu machen, das ist, warum ich diese Frage stelle. –