From: Keith Packard Date: Fri, 7 Feb 2020 07:21:02 +0000 (-0800) Subject: altosdroid: Check if the telem service is running when bluetooth gets enabled X-Git-Tag: android-22~1 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=d0891fbdcc13a61836462525edab776366f86a24 altosdroid: Check if the telem service is running when bluetooth gets enabled 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 --- diff --git a/altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/AltosDroid.java index 88168289..155b8069 100644 --- a/altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/AltosDroid.java @@ -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"); + } } }