Skip to content

Commit 3d193d9

Browse files
committed
Handle returning a result from automatic up navigation from another
task. When navigating up from a different task, if the current activity has a result set only finish the current activity instead of trying finishAffinity. Log this so that developers know why this behavior is happening. Bug 6465336 Change-Id: Ic7cec6f0c0d5861296091e2aea9344309f5fc600
1 parent a7ea0d3 commit 3d193d9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

core/java/android/app/Activity.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2713,7 +2713,16 @@ public boolean onNavigateUp() {
27132713
onCreateNavigateUpTaskStack(b);
27142714
onPrepareNavigateUpTaskStack(b);
27152715
b.startActivities();
2716-
finishAffinity();
2716+
2717+
// We can't finishAffinity if we have a result.
2718+
// Fall back and simply finish the current activity instead.
2719+
if (mResultCode != RESULT_CANCELED || mResultData != null) {
2720+
// Tell the developer what's going on to avoid hair-pulling.
2721+
Log.i(TAG, "onNavigateUp only finishing topmost activity to return a result");
2722+
finish();
2723+
} else {
2724+
finishAffinity();
2725+
}
27172726
} else {
27182727
navigateUpTo(upIntent);
27192728
}

0 commit comments

Comments
 (0)