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:
parent
9f32185b78
commit
876ea68622
|
|
@ -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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user