From 95a4609b90abe02474c815c216780a1383f13cb2 Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Wed, 14 Aug 2013 11:17:25 -0700 Subject: [PATCH] Throw exception in FragmentManager when queuing to a destroyed activity Change-Id: I0522cf27fd423070f7578c1c43c1f05a335810bf --- core/java/android/app/FragmentManager.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java index 7358f735ae360..a7789d6c0b70f 100644 --- a/core/java/android/app/FragmentManager.java +++ b/core/java/android/app/FragmentManager.java @@ -1328,12 +1328,19 @@ final class FragmentManagerImpl extends FragmentManager { } } + /** + * Adds an action to the queue of pending actions. + * + * @param action the action to add + * @param allowStateLoss whether to allow loss of state information + * @throws IllegalStateException if the activity has been destroyed + */ public void enqueueAction(Runnable action, boolean allowStateLoss) { if (!allowStateLoss) { checkStateLoss(); } synchronized (this) { - if (mActivity == null) { + if (mDestroyed || mActivity == null) { throw new IllegalStateException("Activity has been destroyed"); } if (mPendingActions == null) {