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:
Greg Pomerantz 2026-08-21 19:52:33 -04:00
parent 9f32185b78
commit 876ea68622
2 changed files with 5 additions and 1 deletions

BIN
Ble.jar

Binary file not shown.

View File

@ -50,7 +50,11 @@ public class BlessedConnect extends Fragment {
Activity act = (Activity)ctx; Activity act = (Activity)ctx;
FragmentTransaction ft = act.getFragmentManager().beginTransaction(); FragmentTransaction ft = act.getFragmentManager().beginTransaction();
ft.add(inst, "BlessedConnect"); ft.add(inst, "BlessedConnect");
ft.commitNow(); if (android.os.Build.VERSION.SDK_INT >= 24) {
ft.commitNowAllowingStateLoss();
} else {
ft.commitNow();
}
} }
}); });
} }