Skip to content

Commit deb0f20

Browse files
author
Martijn Coenen
committed
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
1 parent 69e640e commit deb0f20

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

core/java/android/nfc/NfcFragment.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ public static void remove(Activity activity) {
4848
FragmentManager manager = activity.getFragmentManager();
4949
Fragment fragment = manager.findFragmentByTag(FRAGMENT_TAG);
5050
if (fragment != null) {
51-
manager.beginTransaction().remove(fragment).commit();
51+
// We allow state loss at this point, because the state is only
52+
// lost when activity is being paused *AND* subsequently destroyed.
53+
// In that case, the app will setup foreground dispatch again anyway.
54+
manager.beginTransaction().remove(fragment).commitAllowingStateLoss();
5255
}
5356
}
5457

0 commit comments

Comments
 (0)