ActivityStack lastStack = mStackSupervisor.getLastStack();
if (next.app != null && next.app.thread != null) {
- if (DEBUG_SWITCH) Slog.v(TAG_SWITCH, "Resume running: " + next);
+ if (DEBUG_SWITCH) Slog.v(TAG_SWITCH, "Resume running: " + next
+ + " stopped=" + next.stopped + " visible=" + next.visible);
// This activity is now becoming visible.
- if (!next.visible) {
+ if (!next.visible || next.stopped) {
mWindowManager.setAppVisibility(next.appToken, true);
}
intentActivity.setTaskToAffiliateWith(mSourceRecord.task);
}
mMovedHome = true;
- final ActivityStack launchStack =
- getLaunchStack(mStartActivity, mLaunchFlags, mStartActivity.task,
- mOptions, true);
- if (launchStack == null || launchStack == mTargetStack) {
- // We only want to move to the front, if we aren't going to launch on a
- // different stack. If we launch on a different stack, we will put the
- // task on top there.
- mTargetStack.moveTaskToFrontLocked(intentActivity.task, mNoAnimation,
- mOptions, mStartActivity.appTimeTracker, "bringingFoundTaskToFront");
- mMovedToFront = true;
+
+ // If the launch flags carry both NEW_TASK and CLEAR_TASK, the task's activities
+ // will be cleared soon by ActivityStarter in setTaskFromIntentActivity().
+ // So no point resuming any of the activities here, it just wastes one extra
+ // resuming, plus enter AND exit transitions.
+ // Here we only want to bring the target stack forward. Transition will be applied
+ // to the new activity that's started after the old ones are gone.
+ final boolean willClearTask =
+ (mLaunchFlags & (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK))
+ == (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK);
+ if (!willClearTask) {
+ final ActivityStack launchStack = getLaunchStack(
+ mStartActivity, mLaunchFlags, mStartActivity.task, mOptions, true);
+ if (launchStack == null || launchStack == mTargetStack) {
+ // We only want to move to the front, if we aren't going to launch on a
+ // different stack. If we launch on a different stack, we will put the
+ // task on top there.
+ mTargetStack.moveTaskToFrontLocked(
+ intentActivity.task, mNoAnimation, mOptions,
+ mStartActivity.appTimeTracker, "bringingFoundTaskToFront");
+ mMovedToFront = true;
+ }
+ mOptions = null;
}
updateTaskReturnToType(intentActivity.task, mLaunchFlags, focusStack);
- mOptions = null;
}
}
if (!mMovedToFront && mDoResume) {
wtoken.appDied = false;
wtoken.removeAllWindows();
} else if (visible) {
- if (DEBUG_ADD_REMOVE) Slog.v(
- TAG_WM, "No longer Stopped: " + wtoken);
- wtoken.mAppStopped = false;
mOpeningApps.add(wtoken);
wtoken.startingMoved = false;
- // If the token is currently hidden (should be the
- // common case), then we need to set up to wait for
- // its windows to be ready.
- if (wtoken.hidden) {
+ // If the token is currently hidden (should be the common case), or has been
+ // stopped, then we need to set up to wait for its windows to be ready.
+ if (wtoken.hidden || wtoken.mAppStopped) {
wtoken.allDrawn = false;
wtoken.deferClearAllDrawn = false;
wtoken.waitingToShow = true;
wtoken.sendAppVisibilityToClients();
}
}
+ if (DEBUG_ADD_REMOVE) Slog.v(
+ TAG_WM, "No longer Stopped: " + wtoken);
+ wtoken.mAppStopped = false;
}
// If we are preparing an app transition, then delay changing