altosdroid: Check if the telem service is running when bluetooth gets enabled
authorKeith Packard <keithp@keithp.com>
Fri, 7 Feb 2020 07:21:02 +0000 (23:21 -0800)
committerKeith Packard <keithp@keithp.com>
Fri, 7 Feb 2020 07:21:02 +0000 (23:21 -0800)
Make sure we aren't trying to send a message when the telem service is
shut down and the pointer is null.

Signed-off-by: Keith Packard <keithp@keithp.com>
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) {
        }
 
        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");
+                       }
                }
        }
 
                }
        }