diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 1486a1d6823a0..13690bc4861de 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -4078,10 +4078,19 @@ public final class ActivityManagerService extends ActivityManagerNative implemen System.identityHashCode(r), r.task.taskId, r.shortComponentName, reason); r.task.numActivities--; - if (r.frontOfTask && index < (mHistory.size()-1)) { + if (index < (mHistory.size()-1)) { HistoryRecord next = (HistoryRecord)mHistory.get(index+1); if (next.task == r.task) { - next.frontOfTask = true; + if (r.frontOfTask) { + // The next activity is now the front of the task. + next.frontOfTask = true; + } + if ((r.intent.getFlags()&Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) != 0) { + // If the caller asked that this activity (and all above it) + // be cleared when the task is reset, don't lose that information, + // but propagate it up to the next activity. + next.intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); + } } }