@Override public void finish() { super.finish(); if (shouldFinishRootActivity()) { TiApplication app = getTiApp(); if (app != null) { TiRootActivity rootActivity = app.getRootActivity(); if (rootActivity != null && !(rootActivity.equals(this)) && !rootActivity.isFinishing()) { rootActivity.finish(); } else if (rootActivity == null && !app.isRestartPending()) { // When the root activity has been killed and garbage collected and the app is not // scheduled to restart, // we need to force finish the root activity while this activity has an intent to finish // root. // This happens when the "Don't keep activities" option is enabled and the user stays in // some activity // (eg. heavyweight window, tabgroup) other than the root activity for a while and then he // wants to back // out the app. app.setForceFinishRootActivity(true); } } } }
@Override public void finish() { TiDict data = new TiDict(); for (WeakReference<TiContext> contextRef : contexts) { if (contextRef.get() != null) { contextRef.get().dispatchEvent("close", data, proxy); } } if (createdContext != null && createdContext.get() != null) { createdContext.get().dispatchEvent("close", data, proxy); } boolean animate = true; Intent intent = getIntent(); if (intent != null) { if (intent.getBooleanExtra("finishRoot", false)) { if (getApplication() != null) { TiApplication tiApp = getTiApp(); if (tiApp != null) { TiRootActivity rootActivity = tiApp.getRootActivity(); if (rootActivity != null) { rootActivity.finish(); } } } } animate = intent.getBooleanExtra("animate", animate); } super.finish(); if (!animate) { TiUIHelper.overridePendingTransition(this); } }
public void setRootActivity(TiRootActivity rootActivity) { // TODO consider weakRef this.rootActivity = rootActivity; this.windowHandler = rootActivity; // calculate the display density DisplayMetrics dm = new DisplayMetrics(); rootActivity.getWindowManager().getDefaultDisplay().getMetrics(dm); switch (dm.densityDpi) { case DisplayMetrics.DENSITY_HIGH: { density = "high"; break; } case DisplayMetrics.DENSITY_MEDIUM: { density = "medium"; break; } case DisplayMetrics.DENSITY_LOW: { density = "low"; break; } } if (collectAnalytics()) { analyticsIntent = new Intent(this, TiAnalyticsService.class); analyticsModel = new TiAnalyticsModel(this); needsEnrollEvent = analyticsModel.needsEnrollEvent(); if (needsEnrollEvent()) { String deployType = systemProperties.getString("ti.deploytype", "unknown"); postAnalyticsEvent(TiAnalyticsEventFactory.createAppEnrollEvent(this, deployType)); } if (needsStartEvent()) { String deployType = systemProperties.getString("ti.deploytype", "unknown"); postAnalyticsEvent(TiAnalyticsEventFactory.createAppStartEvent(this, deployType)); } } else { needsEnrollEvent = false; needsStartEvent = false; Log.i(LCAT, "Analytics have been disabled"); } }