From d300a95e393c092bceb5d4b8ff6c30912bc5a436 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 15 Jan 2021 13:37:30 +0100 Subject: [PATCH] prevent NPE --- .../nightscout/androidaps/queue/QueueThread.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java b/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java index 0eac5ff630..9dbd2c3ef4 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java @@ -81,11 +81,13 @@ public class QueueThread extends Thread { pump.stopConnecting(); pump.disconnect("watchdog"); SystemClock.sleep(1000); - BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); - mBluetoothAdapter.disable(); - SystemClock.sleep(1000); - mBluetoothAdapter.enable(); - SystemClock.sleep(1000); + BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); + if (bluetoothAdapter != null) { + bluetoothAdapter.disable(); + SystemClock.sleep(1000); + bluetoothAdapter.enable(); + SystemClock.sleep(1000); + } //start over again once after watchdog barked //Notification notification = new Notification(Notification.OLD_NSCLIENT, "Watchdog", Notification.URGENT); //rxBus.send(new EventNewNotification(notification));