Skip to content

Commit e095cea

Browse files
adampAndroid (Google) Code Review
authored andcommitted
Merge "Handle returning a result from automatic up navigation from another task." into jb-dev
2 parents 7a59c5a + 3d193d9 commit e095cea

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)