Use commitNowAllowingStateLoss (API 24+) for fragment registration
The register() runnable can run after the activity has saved its state (e.g. app started in the background), in which case commitNow throws IllegalStateException and crashes the app. Rebuild Ble.jar.
This commit is contained in:
+5
-1
@@ -50,7 +50,11 @@ public class BlessedConnect extends Fragment {
|
||||
Activity act = (Activity)ctx;
|
||||
FragmentTransaction ft = act.getFragmentManager().beginTransaction();
|
||||
ft.add(inst, "BlessedConnect");
|
||||
ft.commitNow();
|
||||
if (android.os.Build.VERSION.SDK_INT >= 24) {
|
||||
ft.commitNowAllowingStateLoss();
|
||||
} else {
|
||||
ft.commitNow();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user