File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
androidBluetoothSerial/src/main/java/com/harrysoft/androidbluetoothserial Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 66import android .util .ArrayMap ;
77
88import java .io .Closeable ;
9+ import java .io .InputStream ;
10+ import java .io .StringWriter ;
11+ import java .io .Writer ;
912import java .util .ArrayList ;
13+ import java .util .Iterator ;
1014import java .util .List ;
1115import java .util .Map ;
1216import java .util .UUID ;
@@ -118,10 +122,12 @@ public void closeDevice(SimpleBluetoothDeviceInterface deviceInterface) {
118122 */
119123 @ Override
120124 public void close () {
121- for (Map .Entry <String , BluetoothSerialDevice > d : devices .entrySet ()) {
125+ for (Iterator <Map .Entry <String , BluetoothSerialDevice >> iterator = devices .entrySet ().iterator (); iterator .hasNext ();) {
126+ Map .Entry <String , BluetoothSerialDevice > deviceEntry = iterator .next ();
122127 try {
123- d .getValue ().close ();
124- } catch (Exception ignored ) {}
128+ deviceEntry .getValue ().close ();
129+ } catch (Throwable ignored ) {}
130+ iterator .remove ();
125131 }
126132 }
127133}
You can’t perform that action at this time.
0 commit comments