浏览代码

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

Sam Lantinga 7 年之前
父节点
当前提交
c2791fc60d
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java

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