BluetoothSerial
BluetoothSerial copied to clipboard
Some data received is wrong in Android 8.0
My app receive approximately 160k bytes of data from connected device. It work normal in Android 7.0 and below, but some data (approximately 2k bytes) received is wrong in Android 8.0. The failure rate is 80%. After I test, I found the wrong data has occurred in BluetoothSerialService.java.
bytes = mmInStream.read(buffer); // Get wrong data in buffer
String data = new String(buffer, 0, bytes);
I also try increase buffer size or add some delay after read, but it's useless. I'm sure the data send from device is correct. Please help me to figure out what happened or how to handle this. Thanks.