Fix `java.lang.IllegalStateException: Fragment PreferencesConnection{41fffa88} not attached to Activity` crash in settings fragments.