altosdroid: Check if the telem service is running when bluetooth gets enabled
[fw/altos] / altosdroid / app / src / main / java / org / altusmetrum / AltosDroid / AltosDroid.java
index 881682892c39132e89fbd3fb1f729a46bc03a6ec..155b8069a5da56fc31c3e2554069e76c890273d3 100644 (file)
@@ -959,10 +959,12 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener,
        }
 
        private void bluetoothEnabled(Intent data) {
-               try {
-                       mService.send(Message.obtain(null, TelemetryService.MSG_BLUETOOTH_ENABLED, null));
-               } catch (RemoteException e) {
-                       AltosDebug.debug("send BT enabled message failed");
+               if (mService != null) {
+                       try {
+                               mService.send(Message.obtain(null, TelemetryService.MSG_BLUETOOTH_ENABLED, null));
+                       } catch (RemoteException e) {
+                               AltosDebug.debug("send BT enabled message failed");
+                       }
                }
        }