Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-26964

Android: Calling child window's close() method back to TabGroup fails if "Don't keep activities" is enabled


    • Story Points:
    • Sprint:
      2019 Sprint 8, 2019 Sprint 9, 2019 Sprint 10


      If Android "Developer Options" setting "Don't keep activities" is enabled, then calling the close() method on a child window which navigates back to a TabGroup will do the following depending on the Titanium version:

      • 8.0.0 and above: Shows a blank window.
      • 7.2.1 < 8.0.0: Causes a crash.
      • 7.2.0 and below: Shows a blank window.

      This is not an issue when tapping the Android "Back" button on the child window. It's only an issue when calling the child window's close() method.

      As of Titanium 7.2.1, back-navigating from a child window exits out of the app when "Don't keep activities" is enabled. Titanium no longer "restores" parent windows due to the memory leak fixes made in 7.2.1. This is a separate issue.

      Steps to reproduce:

      1. Go to the Android device's main "Settings" screen.
      2. Tap on "System" under "Settings.
      3. Tap on "Developer options" under "System" settings.
      4. Enable "Don't keep activities", which should be near the bottom of the list.
      5. Build and run the below code on the above Android device.
      6. Tap on the "Open Child Window" button.
      7. Tap on the "Close Window" button.
      8. Notice that the TabGoup will either be blank or the app will crash.

      function createTab(title) {
      	var window = Ti.UI.createWindow({ title: title });
      		text: title + " View",
      		top: "25%",
      	var openButton = Ti.UI.createButton({
      		title: "Open Child Window",
      		top: "50%",
      	openButton.addEventListener("click", function() {
      		var childWindow = Ti.UI.createWindow({
      			title: title + " Child Window",
      			backgroundColor: "white",
      		var closeButton = Ti.UI.createButton({
      			title: "Close Window",
      		closeButton.addEventListener("click", function() {
      	var tab = Ti.UI.createTab({
      		title: title,
      		window: window,
      	return tab;
      var tabGroup = Ti.UI.createTabGroup({
      	title: "TabGroup Parent Test",
      	tabs: [createTab("Tab 1"), createTab("Tab 2"), createTab("Tab 3")],

      Result on Titanium 7.2.0 and Below:
      TabGroup will be empty. No tabs are shown.

      Result on Titanium 8.0.0:
      TabGroup will be empty. No tabs are shown.

      Result on Titanium 7.2.1 - 7.5.1:
      The app will crash for these Titanium versions.

      [ERROR] :  TiExceptionHandler: (main) [89797,89797] Attempt to invoke virtual method 'android.app.Activity ti.modules.titanium.ui.TabGroupProxy.getActivity()' on a null object reference
      [ERROR] :  TiExceptionHandler:
      [ERROR] :  TiExceptionHandler:     ti.modules.titanium.ui.widget.tabgroup.TiUIAbstractTab.getContentView(TiUIAbstractTab.java:55)
      [ERROR] :  TiExceptionHandler:     ti.modules.titanium.ui.widget.tabgroup.TiUIActionBarTab$TabFragment.onCreateView(TiUIActionBarTab.java:52)
      [ERROR] :  TiExceptionHandler:     android.support.v4.app.Fragment.performCreateView(Fragment.java:2346)
      [ERROR] :  TiExceptionHandler:     android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1428)
      [ERROR] :  TiExceptionHandler:     android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1759)
      [ERROR] :  TiExceptionHandler:     android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1827)
      [ERROR] :  TiExceptionHandler:     android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3244)
      [ERROR] :  TiExceptionHandler:     android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3200)
      [ERROR] :  TiExceptionHandler:     android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:195)
      [ERROR] :  TiExceptionHandler:     android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:597)
      [ERROR] :  TiExceptionHandler:     android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:177)
      [ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.TiBaseActivity.onStart(TiBaseActivity.java:1504)
      [ERROR] :  TiExceptionHandler:     android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1391)
      [ERROR] :  TiExceptionHandler:     android.app.Activity.performStart(Activity.java:7157)
      [ERROR] :  TiExceptionHandler:     android.app.ActivityThread.handleStartActivity(ActivityThread.java:2937)
      [ERROR] :  TiExceptionHandler:     android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180)
      [ERROR] :  TiExceptionHandler:     android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165)
      [ERROR] :  TiExceptionHandler:     android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142)
      [ERROR] :  TiExceptionHandler:     android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
      [ERROR] :  TiExceptionHandler:     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
      [ERROR] :  TiExceptionHandler:     android.os.Handler.dispatchMessage(Handler.java:106)
      [ERROR] :  TiExceptionHandler:     android.os.Looper.loop(Looper.java:193)
      [ERROR] :  TiExceptionHandler:     android.app.ActivityThread.main(ActivityThread.java:6669)
      [ERROR] :  TiExceptionHandler:     java.lang.reflect.Method.invoke(Native Method)
      [ERROR] :  TiExceptionHandler:     com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
      [ERROR] :  TiExceptionHandler:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)


          Issue Links



              • Assignee:
                jquick Joshua Quick
                jquick Joshua Quick
                Gary Mathews
                Lokesh Choudhary
              • Watchers:
                4 Start watching this issue


                • Created:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Integration