summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Martijn Coenen <maco@google.com> 2011-10-31 14:41:13 -0700
committer Martijn Coenen <maco@google.com> 2011-10-31 15:42:13 -0700
commitdeb0f20c3d1abf68c7e0642b6c7e3fa3cc8b36be (patch)
tree76572f7c23ec5e09a6b93dd4103fdc46d75fda55
parent69e640ee84fc218d6318acaf73a1c1841d7fba6b (diff)
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
-rw-r--r--core/java/android/nfc/NfcFragment.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/java/android/nfc/NfcFragment.java b/core/java/android/nfc/NfcFragment.java
index 17278dc04cc7..d6b15ad1bf5a 100644
--- a/core/java/android/nfc/NfcFragment.java
+++ b/core/java/android/nfc/NfcFragment.java
@@ -48,7 +48,10 @@ public final class NfcFragment extends Fragment {
FragmentManager manager = activity.getFragmentManager();
Fragment fragment = manager.findFragmentByTag(FRAGMENT_TAG);
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();
}
}