From b70f3dff01e7e1e85f77cf0b0b2eaba8200eb82c Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Tue, 7 Apr 2009 16:07:59 -0700 Subject: [PATCH] Preserve an Activity's setIntent() state across relaunches Previously any Intent designated by setIntent() would be lost when the Activity was shut down and restarted due to orientation change. Now the custom intent is preserved across the relaunch. Bug: b/1743425 --- core/java/android/app/Activity.java | 2 +- core/java/android/app/ActivityThread.java | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 849a37dc95a9..9b1f0f97171f 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -611,7 +611,7 @@ public class Activity extends ContextThemeWrapper private IBinder mToken; /*package*/ String mEmbeddedID; private Application mApplication; - private Intent mIntent; + /*package*/ Intent mIntent; private ComponentName mComponent; /*package*/ ActivityInfo mActivityInfo; /*package*/ ActivityThread mMainThread; diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index d8161936a44d..09862d2705d1 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -1689,7 +1689,7 @@ public final class ActivityThread { r.packageInfo = getPackageInfoNoCheck( r.activityInfo.applicationInfo); - handleLaunchActivity(r); + handleLaunchActivity(r, null); } break; case RELAUNCH_ACTIVITY: { ActivityRecord r = (ActivityRecord)msg.obj; @@ -2109,7 +2109,7 @@ public final class ActivityThread { + ", comp=" + name + ", token=" + token); } - return performLaunchActivity(r); + return performLaunchActivity(r, null); } public final Activity getActivity(IBinder token) { @@ -2159,7 +2159,7 @@ public final class ActivityThread { queueOrSendMessage(H.CLEAN_UP_CONTEXT, cci); } - private final Activity performLaunchActivity(ActivityRecord r) { + private final Activity performLaunchActivity(ActivityRecord r, Intent customIntent) { // System.out.println("##### [" + System.currentTimeMillis() + "] ActivityThread.performLaunchActivity(" + r + ")"); ActivityInfo aInfo = r.activityInfo; @@ -2219,6 +2219,9 @@ public final class ActivityThread { r.lastNonConfigurationInstance, r.lastNonConfigurationChildInstances, config); + if (customIntent != null) { + activity.mIntent = customIntent; + } r.lastNonConfigurationInstance = null; r.lastNonConfigurationChildInstances = null; activity.mStartedActivity = false; @@ -2274,14 +2277,14 @@ public final class ActivityThread { return activity; } - private final void handleLaunchActivity(ActivityRecord r) { + private final void handleLaunchActivity(ActivityRecord r, Intent customIntent) { // If we are getting ready to gc after going to the background, well // we are back active so skip it. unscheduleGcIdler(); if (localLOGV) Log.v( TAG, "Handling launch of " + r); - Activity a = performLaunchActivity(r); + Activity a = performLaunchActivity(r, customIntent); if (a != null) { handleResumeActivity(r.token, false, r.isForward); @@ -3243,6 +3246,7 @@ public final class ActivityThread { } r.activity.mConfigChangeFlags |= configChanges; + Intent currentIntent = r.activity.mIntent; Bundle savedState = null; if (!r.paused) { @@ -3275,7 +3279,7 @@ public final class ActivityThread { r.state = savedState; } - handleLaunchActivity(r); + handleLaunchActivity(r, currentIntent); } private final void handleRequestThumbnail(IBinder token) { -- 2.11.0