Skip to content

Commit

Permalink
[TIMOB-23969] Fix TiBaseActivity.onBackPressed() (#8511)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Mathews authored and sgtcoolguy committed Oct 17, 2016
1 parent fb0212a commit d71f3ba
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ public KrollObject getContext() {
protected TiWindowProxy window;
protected TiViewProxy view;
protected ActivityProxy activityProxy;
protected Activity previousActivity;
protected TiWeakList<ConfigurationChangedListener> configChangedListeners = new TiWeakList<ConfigurationChangedListener>();
protected int orientationDegrees;
protected TiMenuSupport menuHelper;
Expand Down Expand Up @@ -612,7 +611,6 @@ protected void onCreate(Bundle savedInstanceState)
return;
}

previousActivity = tiApp.getRootOrCurrentActivity();
TiApplication.addToActivityStack(this);

// create the activity proxy here so that it is accessible from the activity in all cases
Expand Down Expand Up @@ -862,9 +860,12 @@ public void onBackPressed()
} else {
// there are no parent activities to return to
// override back press to background the activity
if (previousActivity == null || previousActivity == getTiApp().getRootActivity()) {
this.moveTaskToBack(true);
return;
// note: 2 since there should always be TiLaunchActivity and TiActivity
if (TiApplication.activityStack.size() <= 2) {
if (topWindow != null && !TiConvert.toBoolean(topWindow.getProperty(TiC.PROPERTY_EXIT_ON_CLOSE), false)) {
this.moveTaskToBack(true);
return;
}
}

// If event is not handled by custom callback allow default behavior.
Expand Down

0 comments on commit d71f3ba

Please sign in to comment.