diff --git a/androidgcs/src/org/openpilot/androidgcs/telemetry/OPTelemetryService.java b/androidgcs/src/org/openpilot/androidgcs/telemetry/OPTelemetryService.java index 58bfc8918..2e518b7e0 100644 --- a/androidgcs/src/org/openpilot/androidgcs/telemetry/OPTelemetryService.java +++ b/androidgcs/src/org/openpilot/androidgcs/telemetry/OPTelemetryService.java @@ -140,14 +140,15 @@ public class OPTelemetryService extends Service { case MSG_DISCONNECT: Toast.makeText(getApplicationContext(), "Disconnect requested", Toast.LENGTH_SHORT).show(); terminate = true; - activeTelem.interrupt(); - try { - activeTelem.join(); - } catch (InterruptedException e) { - e.printStackTrace(); + if (activeTelem != null) { + activeTelem.interrupt(); + try { + activeTelem.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + activeTelem = null; } - activeTelem = null; - Intent intent = new Intent(); intent.setAction(INTENT_ACTION_DISCONNECTED); sendBroadcast(intent,null);