c19354837 / react-native-system-setting

A library to access system setting, and change it easily. eg: volume, brightness, wifi
MIT License
442 stars 159 forks source link

SystemSetting.java Receiver not registered: com.ninty.system.setting.SystemSetting$4@f8b3066 #125

Open pkt-dev opened 3 years ago

pkt-dev commented 3 years ago

Causing app foreground service to crash, partial stack:

Caused by: java.lang.IllegalArgumentException: Receiver not registered: com.ninty.system.setting.SystemSetting$4@f8b3066 at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:1430) at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1564) at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:664) at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:664) at com.ninty.system.setting.SystemSetting.onHostDestroy(SystemSetting.java:558) at com.facebook.react.bridge.ReactContext.onHostDestroy(ReactContext.java:254)

Looks like there might be a typo here:

        if (locationModeBR != null) {
            mContext.unregisterReceiver(locationModeBR);
            locationBR = null;
        }

Also was going to put trycatch around the unregisters. Here is the pr -> https://github.com/c19354837/react-native-system-setting/pull/124