diff --git a/MyTracks/src/com/google/android/apps/mytracks/services/sensors/BluetoothConnectionManager.java b/MyTracks/src/com/google/android/apps/mytracks/services/sensors/BluetoothConnectionManager.java index 3f95db95f..3f1c6ba27 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/services/sensors/BluetoothConnectionManager.java +++ b/MyTracks/src/com/google/android/apps/mytracks/services/sensors/BluetoothConnectionManager.java @@ -394,8 +394,10 @@ public class BluetoothConnectionManager { offset = 0; - // Send the obtained bytes to the UI Activity - handler.obtainMessage(MESSAGE_READ, bytes, -1, buffer) + // Send copy of the obtained bytes to the UI Activity. + // Avoids memory inconsistency issues. + byte[] b = buffer.clone(); + handler.obtainMessage(MESSAGE_READ, bytes, -1, b) .sendToTarget(); } catch (IOException e) { Log.e(Constants.TAG, "disconnected", e);