diff options
author | Vitaly Chekryzhev <13hakta@gmail.com> | 2016-01-21 17:51:01 +0900 |
---|---|---|
committer | Yuichi Araki <yaraki@google.com> | 2016-01-21 17:51:01 +0900 |
commit | 1d1672e3b9ccfbde2c2998c3b27f18a0b09768c0 (patch) | |
tree | f615c7349ca1839d138ab9452559bde6ff806b10 | |
parent | 90ec985bba5710f733d8959530163a480d1e84d4 (diff) | |
download | android-1d1672e3b9ccfbde2c2998c3b27f18a0b09768c0.tar.gz |
BluetoothChat: Fix crash on disconnection
https://github.com/googlesamples/android-BluetoothChat/pull/1
Update BluetoothChatService.java
Read input stream only when connection established. Otherwise there will
be exceptions on disconnection and disconnection when program finish.
Change-Id: I4fb93cee93c271d2159c7811a83474699eb3ae0b
-rw-r--r-- | connectivity/bluetooth/BluetoothChat/Application/src/main/java/com/example/android/bluetoothchat/BluetoothChatService.java | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/connectivity/bluetooth/BluetoothChat/Application/src/main/java/com/example/android/bluetoothchat/BluetoothChatService.java b/connectivity/bluetooth/BluetoothChat/Application/src/main/java/com/example/android/bluetoothchat/BluetoothChatService.java index b88b160d..a1e7cc01 100644 --- a/connectivity/bluetooth/BluetoothChat/Application/src/main/java/com/example/android/bluetoothchat/BluetoothChatService.java +++ b/connectivity/bluetooth/BluetoothChat/Application/src/main/java/com/example/android/bluetoothchat/BluetoothChatService.java @@ -473,7 +473,7 @@ public class BluetoothChatService { int bytes; // Keep listening to the InputStream while connected - while (true) { + while (mState == STATE_CONNECTED) { try { // Read from the InputStream bytes = mmInStream.read(buffer); |