From c2791fc60d61b25e2e4c0ca55ff07401683e05f1 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 21 Aug 2018 11:59:13 -0700 Subject: [PATCH] Don't crash if the app doesn't have Bluetooth permissions --- .../app/src/main/java/org/libsdl/app/HIDDeviceManager.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java b/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java index 2345a84e5..0759efff6 100644 --- a/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java +++ b/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java @@ -366,7 +366,11 @@ public class HIDDeviceManager { } protected void shutdownBluetooth() { - mContext.unregisterReceiver(mBluetoothBroadcast); + try { + mContext.unregisterReceiver(mBluetoothBroadcast); + } catch (Exception e) { + // We may not have registered, that's okay + } } // Chromebooks do not pass along ACTION_ACL_CONNECTED / ACTION_ACL_DISCONNECTED properly.