diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 520ebc9023c63..fcc2bd6d00326 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -4007,6 +4007,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A private boolean transferStartingWindow(@NonNull ActivityRecord fromActivity) { final WindowState tStartingWindow = fromActivity.mStartingWindow; if (tStartingWindow != null && fromActivity.mStartingSurface != null) { + if (tStartingWindow.getParent() == null) { + // The window has been detached from the parent, so the window cannot be transfer + // to another activity because it may be in the remove process. + // Don't need to remove the starting window at this point because that will happen + // at #postWindowRemoveCleanupLocked + return false; + } // In this case, the starting icon has already been displayed, so start // letting windows get shown immediately without any more transitions. if (fromActivity.mVisible) {