Ver Fonte

Don't crash if the app doesn't have Bluetooth permissions

Sam Lantinga há 6 anos atrás
pai
commit
c2791fc60d

+ 5 - 1
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.