Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit deb0f20c authored by Martijn Coenen's avatar Martijn Coenen
Browse files

Fix disableForegroundNdefPush crash.

It crashed due to the fact that we're committing a fragment change
after onSaveInstanceState() is called. Instead, commit without
storing the state - as the NfcFragment is something that needs
to be setup explicitly anyway, it is not something the user
expects to be restored.

Bug: 5540962
Change-Id: I5a8cd0e47306f2bbc14b592a0182083bb79cb21a
parent 69e640ee
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -48,7 +48,10 @@ public final class NfcFragment extends Fragment {
        FragmentManager manager = activity.getFragmentManager();
        FragmentManager manager = activity.getFragmentManager();
        Fragment fragment = manager.findFragmentByTag(FRAGMENT_TAG);
        Fragment fragment = manager.findFragmentByTag(FRAGMENT_TAG);
        if (fragment != null) {
        if (fragment != null) {
            manager.beginTransaction().remove(fragment).commit();
            // We allow state loss at this point, because the state is only
            // lost when activity is being paused *AND* subsequently destroyed.
            // In that case, the app will setup foreground dispatch again anyway.
            manager.beginTransaction().remove(fragment).commitAllowingStateLoss();
        }
        }
    }
    }