Bug 1360699 - Finish CustomTabsActivities when leaving. r?walkingice
Looking again, the original motivation for *not* calling finish(), i.e. avoiding Gecko being unloaded from memory, doesn't quite seem to apply and in any case for custom tabs we *have* to finish() the activity, since we're most probably running within another activity's task.
There's also no point in overriding onDone() in SingleTabActivity any more if
- we just do the same thing as GeckoApp's default behaviour, and
- custom tabs now require a different behaviour anyway.
MozReview-Commit-ID: BsP1tMj5DEe
--- a/mobile/android/base/java/org/mozilla/gecko/SingleTabActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/SingleTabActivity.java
@@ -131,26 +131,16 @@ public abstract class SingleTabActivity
return true;
}
// If we end up here, this means that there's no suitable tab we can take over.
// Instead, we'll just open a new tab from the data specified in the intent.
return false;
}
- @Override
- protected void onDone() {
- // Our startup logic should be robust enough to cope with it's tab having been closed even
- // though the activity might survive, so we don't have to call finish() just to make sure
- // that a new tab is opened in that case. This also has the advantage that we'll remain in
- // memory as long as the low-memory killer permits, so we can potentially avoid a costly
- // re-startup of Gecko if the user returns to us soon.
- moveTaskToBack(true);
- }
-
/**
* For us here, mLastSelectedTabId/Hash will hold the tab that will be selected when the
* activity is resumed/recreated, unless
* - it has been explicitly overridden through an intent
* - the tab cannot be found, in which case the URI passed as intent data will instead be
* opened in a new tab.
* Therefore, we only update the stored tab data from those two locations.
*/
--- a/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
@@ -160,16 +160,23 @@ public class CustomTabsActivity extends
// Use its package name to retrieve animation resource
return IntentUtil.getAnimationPackageName(new SafeIntent(getIntent()));
} else {
return super.getPackageName();
}
}
@Override
+ public void onDone() {
+ // We're most probably running within a foreign app's task, so we have no choice what to
+ // call here if we want to allow the user to return to that task's previous activity.
+ finish();
+ }
+
+ @Override
public void finish() {
super.finish();
final SafeIntent intent = new SafeIntent(getIntent());
// When 3rd party app launch this Activity, it could also specify custom exit-animation.
if (IntentUtil.hasExitAnimation(intent)) {
usingCustomAnimation = true;
overridePendingTransition(IntentUtil.getEnterAnimationRes(intent),